...
Code Block | ||
---|---|---|
| ||
#include <SoftwareSerial.h> // pin 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 pololu(6, 7); int pos = 0; void setup() { Serial.begin(9600); pololu.begin(9600); } void loop() { Serial.println(pos); // set position for eight servos simultaneously for(int i=0; i<8; i++) { setPosition(i, pos); } pos++; if(pos >= 255) { pos = 0; } delay(10); } void setPosition(int servo, int pos) { pololu.write(0xFF); // write synchronization flag pololu.write(servo + 8); // write servo number (without +8 == 90°) pololu.write(pos); // write position } |
...