#include <SoftwareSerial.h>
// Pin 6 is to receive from the controller and does not need to be connected
SoftwareSerial servoController(6, 7);
int curpos = 0;
void setup() {
Serial.begin(9600);
servoController.begin(9600);
}
void loop() {
Serial.println(curpos);
// set position for three servos simultaneously
for(int i=0; i<3; i++) {
setPosition((byte)i, (byte)curpos);
}
curpos++;
if(curpos == 255) {
curpos = 0;
}
delay(10);
}
void setPosition(byte servo, byte pos) {
servoController.write(0xFF);
servoController.write(servo);
servoController.write(pos);
} |