#include <SoftwareSerial.h>
// Pinpin 6 is to receive from the controller and does not need to be connected
// pin 7 needs to be connect to the serial data input of the board
SoftwareSerial servoControllerpololu(6, 7);
int pos = 0;
void setup() {
Serial.begin(9600);
servoControllerpololu.begin(9600);
}
void loop() {
Serial.println(pos);
// set position for threeeight servos simultaneously
for(int i=0; i<3i<8; i++) {
setPosition((byte)i, (byte)pos);
}
pos++;
if(pos == 255) {
pos = 0;
}
delay(10);
}
void setPosition(byteint servo, byteint pos) {
servoControllerpololu.write(0xFF);
servoControllerpololu.write((byte)servo);
servoControllerpololu.write((byte)pos);
} |