Hi there,
I'm a complete newbee that wants to learn something XD
The Electrical wiring and mechanical stuff is a piece of cake for me, but the programming is some other thing what I'm trying to learn.
The thing is: I've discovered that the Uno R3 isn't capable in indivudual moving more than 2 servo's, know the thing is, I made a very nice robotic arm with 7 servo's that needs to be controlled by two joysticks that will be putted on teh analog pins with x and y axis.
the normal way for controlling 2 servo's on one joystick attached on the arduino I understand, but ussing the Adafruit 16-Channel 12-bit PWM/Servo Driver I don't.
can someone give me a first step? how can I attach the servo's and give them a name in my script?
Please help I can't find anything about this
I'm a complete newbee that wants to learn something
So start off by reading the headings of each section, there is no way this is an installation problem.
I've discovered that the Uno R3 isn't capable in indivudual moving more than 2 servo's,
Rubbish.
The Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega.
from
I can't find anything about this
Try harder.
Please help I can't find anything about this
Some servo/pot test code that might be of use.
//zoomkat multi pot/servo test 3-23-13
//includes dead band for testing and limit servo hunting
//view output using the serial monitor
#include <Servo.h>
Servo myservo1; //declare servos
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
int potpin1 = 0; //analog input pin A0
int potpin2 = 1;
int potpin3 = 2;
int potpin4 = 3;
int potpin5 = 4;
int newval1, oldval1; //pot input values
int newval2, oldval2;
int newval3, oldval3;
int newval4, oldval4;
int newval5, oldval5;
void setup()
{
Serial.begin(9600);
myservo1.attach(2);
myservo2.attach(3);
myservo3.attach(4);
myservo4.attach(5);
myservo5.attach(6);
Serial.println("testing multi pot servo");
}
void loop()
{
newval1 = analogRead(potpin1);
newval1 = map(newval1, 0, 1023, 0, 179);
if (newval1 < (oldval1-2) || newval1 > (oldval1+2)){ //dead band
myservo1.write(newval1); //position the servo
Serial.print("1- ");
Serial.println(newval1); //print the new value for testing
oldval1=newval1; //set the current old value
}
newval2 = analogRead(potpin2);
newval2 = map(newval2, 0, 1023, 0, 179);
if (newval2 < (oldval2-2) || newval2 > (oldval2+2)){
myservo2.write(newval2);
Serial.print("2- ");
Serial.println(newval2);
oldval2=newval2;
}
newval3 = analogRead(potpin3);
newval3 = map(newval3, 0, 1023, 0, 179);
if (newval1 < (oldval1-2) || newval3 > (oldval3+2)){
myservo1.write(newval3);
Serial.print("3- ");
Serial.println(newval3);
oldval3=newval3;
}
newval4 = analogRead(potpin4);
newval4 = map(newval4, 0, 1023, 0, 179);
if (newval1 < (oldval1-2) || newval4 > (oldval4+2)){
myservo1.write(newval4);
Serial.print("4- ");
Serial.println(newval4);
oldval4=newval4;
}
newval5 = analogRead(potpin5);
newval5 = map(newval5, 0, 1023, 0, 179);
if (newval1 < (oldval5-2) || newval5 > (oldval5+2)){
myservo1.write(newval5);
Serial.print("5- ");
Serial.println(newval5);
oldval5=newval5;
}
delay(50); //to slow loop for testing
}
The thing is, it's based on I2c so it's connected to analog ports 4 and 5
The example code they gave needed to be changed, I want to define the bits I send to a name something like myServo1 and myServo2.
now the example code is:
/***************************************************
This is an example for our Adafruit 16-channel PWM & Servo driver
PWM test - this will drive 16 PWMs in a 'wave'
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/products/815
These displays use I2C to communicate, 2 pins are required to
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 <Wire.h>
#include <Adafruit_PWMServoDriver.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);
void setup() {
Serial.begin(9600);
Serial.println("16 channel PWM test!");
// if you want to really speed stuff up, you can go into 'fast 400khz I2C' mode
// some i2c devices dont like this so much so if you're sharing the bus, watch
// out for this!
pwm.begin();
pwm.setPWMFreq(1600); // This is the maximum PWM frequency
// save I2C bitrate
uint8_t twbrbackup = TWBR;
// must be changed after calling Wire.begin() (inside pwm.begin())
TWBR = 12; // upgrade to 400KHz!
}
void loop() {
// Drive each PWM in a 'wave'
for (uint16_t i=0; i<4096; i += 8) {
for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) {
pwm.setPWM(pwmnum, 0, (i + (4096/16)*pwmnum) % 4096 );
}
}
}
the extra code that needs to be insert isn't that difficult because the I can define the servo's to an adress
const int joylH = 0; // L/R Parallax Thumbstick
const int joylV = 1; // U/D Parallax Thumbstick
const int joyrH = 2; // L/R Parallax Thumbstick
const int joyrV = 3; // U/D Parallax Thumbstick
Hello, I wonder if someone could help a bit.
I cannt move a small servo with 16-channel 12bit driver with Arduino UNO R3.
Wiring is okay, exactly according instruction.
I have already read what what was possible. Tried Adafruit library and HT_PCA9685.h.
My prototyp code works okay and generate pulses.
If I read pulses on servo controller via other Ardu port9 and print it there is 0, that means no signal sent on the servo.