arduino stuffs
Diffstat (limited to 'car_driver/arduino/arduino.ino')
| -rw-r--r-- | car_driver/arduino/arduino.ino | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/car_driver/arduino/arduino.ino b/car_driver/arduino/arduino.ino index 8e231da..5be4b2d 100644 --- a/car_driver/arduino/arduino.ino +++ b/car_driver/arduino/arduino.ino @@ -6,6 +6,8 @@ const int MOVE_RIGHT[2] = {1, 0}; // move right const int MOVE_BACK[2] = {0, 1}; // move back const int MOVE_STOP[2] = {0, 0}; // stop +#include "drive.h" + void setup() { Serial.begin(9600); Serial.println("initialized"); @@ -35,21 +37,21 @@ void processCommand(const int x, const int y) { } if (x < DEADZONE && x >= 0) { // apply brakes to motora - brakeMotorA(); + motor_a.brake(); } else if (x < 0) { - motorABackward(abs(x) + 155); + motor_a.backward(abs(x) + 155); } else { // positive number: 100 + 155 = 255 - motorAForward(x + 155); + motor_a.forward(x + 155); } if (y < DEADZONE && y >= 0) { // apply brakes to motorb - brakeMotorB(); + motor_b.brake(); } else if (y < 0) { // negative number: -100 + 355 = 255 - motorBBackward(abs(y) + 155); + motor_b.backward(abs(y) + 155); } else { // apply speed to motorb - motorBForward(y + 155); + motor_b.forward(y + 155); } Serial.print("x: "); Serial.print(String(x)); |