git.haldean.org droidcopter / a94311c
Updated firmware to work with new motor controllers Will Brown 11 years ago
1 changed file(s) with 11 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
33 #define MOTOR_ARM_TIME 5000
44 #define MOTOR_ARM_VALUE 20
55 #define MOTOR_COUNT 4
6 #define MOTOR_MAX_COMMAND 160
7 #define MOTOR_MIN_COMMAND 67
8 #define MOTOR_OFF_COMMAND 50
69 #define SPEED_HEADER "NEWSPEED"
710 #define STATUS_LED 13
811 #define STATUS_LED_CYCLES 30000
8588 */
8689 void loop(void) {
8790 if (Serial.available() >= WORD_LENGTH) {
88 int i, j, timeout;
91 int i, j, timeout, buffer_val;
8992 led_cycles = 0;
9093 digitalWrite(STATUS_LED, HIGH);
9194
100103 }
101104
102105 buffer[WORD_LENGTH] = '\0';
103 motors[i].next_speed = map(atoi(buffer), -1, 99, 67, 160);
106 buffer_val = atoi(buffer);
107 if (buffer_val > 0) {
108 motors[i].next_speed = map(atoi(buffer), -1, 99,
109 MOTOR_MIN_COMMAND, MOTOR_MAX_COMMAND);
110 } else {
111 motors[i].next_speed = MOTOR_OFF_COMMAND;
112 }
104113 } else {
105114 Serial.println(BAD_REQUEST);
106115 }