Exemplo n.º 1
0
servoTest::servoTest(byte pin)
{
    _pin=pin;

    _carteAda = Adafruit_PWMServoDriver(0x40);

}
Exemplo n.º 2
0
Hand::Hand() {
    for (int i = 0; i < NUM_FINGERS; ++i) {
        finger[i].setup(i);
    }

    pwmDriver = Adafruit_PWMServoDriver(0x5F);
    pwmDriver.begin();
    pwmDriver.setPWMFreq(24);
}
Adafruit_MotorShield::Adafruit_MotorShield(uint8_t bus, uint8_t addr) {
  _addr = addr;
  _bus = bus;
  _pwm = Adafruit_PWMServoDriver(_bus, _addr);
}
Exemplo n.º 4
0
// keeps track of whether its safe or not to update the servos
uint8_t update_reg_flag = 0;

// variables for the callback
uint16_t timer;
uint8_t  counter = 0;
uint8_t  pwm_active = 1;

uint16_t group_offsets[4] = {0,251,502,753};
uint8_t group_latches[4] = {5,6,7,4};
uint8_t pin_2_num[8] = {0x08,0x04,0x02,0x01, 0x80,0x40,0x20,0x10};

// Use Adafruit PWM Servo Driver Library
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x41);

void Servotor32::begin(){
  // Serial setup moved to .ino setup()

  // Setup pwm output
  pwm.begin();
  pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
  pwm2.begin();
  pwm2.setPWMFreq(60);

  Timer1.initialize(10);
  Timer1.attachInterrupt(callback);

  for(byte i=0; i<SERVOS; i++){
Exemplo n.º 5
0
  interface. For Arduino UNOs, thats SCL -> Analog 5, SDA -> Analog 4

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

// Use the default address for the first board
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40);

// Depending on your servo make, the pulse width min and max may vary, you
// want these to be as small/large as possible without hitting the hard stop
// for max range. You'll have to tweak them as necessary to match the servos you
// have!
#define SERVOMIN 200 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX 450 // this is the 'maximum' pulse length count (out of 4096)

// our servo # counter
uint8_t servo_00 = 4;
uint8_t servo_01 = 5;

// Continuous servo positions
uint16_t BACKWARD = map(0, 0, 180, SERVOMIN, SERVOMAX); // ms, "0"
uint16_t     STOP = map(90, 0, 180, SERVOMIN, SERVOMAX); // ms, "90"
Exemplo n.º 6
0
#include "robot.h"

Adafruit_PWMServoDriver robot::pwm = Adafruit_PWMServoDriver();
float robot::speed_divider = 60;
float adj_speed(int speed) { return static_cast<float>(speed) / robot::speed_divider; }

robot::robot() :
    left_arm(servo(1, left_arm_min, left_arm_min + arm_range)),
    right_arm(servo(0, right_arm_min, right_arm_min - arm_range)),
    head(servo(2, head_center - head_range, head_center + head_range)),
    torso(servo(3, torso_center - torso_range, torso_center + torso_range)),
    tilt(servo(15, tilt_center - tilt_range, tilt_center + tilt_range)),
    left_eye(rgb_led(4)),
    right_eye(rgb_led(8)),
    chest(led_grid(2, 3, 4, 5)),
    voice(speaker(9)){ }

void robot::setup() {
  Serial.println("Hello!");
  pwm.begin();
  pwm.setPWMFreq(60);
  left_arm.setup();
  right_arm.setup();
  head.setup();
  torso.setup();
  tilt.setup();
  left_eye.setup();
  right_eye.setup();
  chest.setup();
  voice.setup();
Exemplo n.º 7
0
MotorController::MotorController()
{
	// Setup pwm
	this->pwm = Adafruit_PWMServoDriver();
}
/* 
 * File:   Servo_Position_Shell.cpp
 * Author: Nickolas Neely
 *
 * Created on February 8, 2016, 12:05 PM
 */

#include <wiringPi.h>
#include "Adafruit_PWMServoDriver.cpp"
#include <iostream>
#include "Servo_Position_Shell.h"


// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);

// Depending on your servo make, the pulse width min and max may vary, you 
// want these to be as small/large as possible without hitting the hard stop
// for max range. You'll have to tweak them as necessary to match the servos you
// have!
#define SERVOMIN  150 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX  600 // this is the 'maximum' pulse length count (out of 4096)

// our servo # counter
uint8_t servo_num;

/**
 * Desc: This function sets up the breakout board communication with I2C