65 Serial.begin(SERIAL_BAUDRATE);
68 for (uint8_t servo_index = 0; servo_index <
SERVOS; servo_index++)
81 servo [servo_index].attach (pin);
82 pinMode (pin, OUTPUT);
102 static int servo_id, servo_angle;
105 if (! Serial.available ())
108 Serial.write (WAIT_RESPONSE);
117 if (servo_id == DUMP_SIGNAL)
129 if (servo_angle == DUMP_SIGNAL)
157 Serial.print (i, DEC);
186 if (i == CANCEL_SIGNAL)
207 if (servo_index >=
SERVOS || servo_index < 0)
213 if (servo_angle > 180)
226 servo_angle = map (servo_angle, 180, 0,
227 limit [servo_index] [MIN_LIM],
limit [servo_index] [MAX_LIM]);
231 servo_angle = map (servo_angle, 0, 180,
232 limit [servo_index] [MIN_LIM],
limit [servo_index] [MAX_LIM]);
237 servo [servo_index].write (servo_angle);
275 buf [i++] = START_RESPONSE;
278 for (
int servo_index = 0; servo_index <
SERVOS; servo_index++)
283 buf [i++] = END_RESPONSE;
285 Serial.write (
buf, i);
293 while (!Serial.available ());
The length of the response to the dump signal.
void serialPrint(const char *s)
uint8_t current_pos[SERVOS]
int getServoIDFromIndex(uint8_t servo_index)
void serialPrintInt(uint8_t i)
void serialPrintIntPretty(const char *pre, uint8_t i, const char *post)
Whether to print debug output to the serial port.
uint8_t default_pos[SERVOS]
The unique identification for this board.
void setServoFromIndex(uint8_t servo_index, uint8_t servo_angle)
char buf[BUFSIZE]
The print buffer.
int getServoIndexFromID(uint8_t servo_id)
int getServoPinFromIndex(uint8_t servo_index)
void setServoFromID(int servo_id, uint8_t servo_angle)