Curtis Sellier / Mbed 2 deprecated Project_Car_Curtis_Non_Tested

Dependencies:   Servo mbed

Committer:
csellier
Date:
Fri Oct 07 15:09:20 2016 +0000
Revision:
1:8c1e3382b4d7
Parent:
0:65fd20a989e9
Child:
2:0b86e6482e4b
Car project program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kmarangi 0:65fd20a989e9 1 #include "mbed.h"
kmarangi 0:65fd20a989e9 2 #include "Servo.h"
kmarangi 0:65fd20a989e9 3 Serial pc(USBTX, USBRX); // USB serial interface
csellier 1:8c1e3382b4d7 4 Servo ServoRight(p21); // continuous rotation hobby servo right
csellier 1:8c1e3382b4d7 5 Servo ServoLeft(p22); // continuous rotation hobby servo left
kmarangi 0:65fd20a989e9 6
kmarangi 0:65fd20a989e9 7 void init_servo() {
kmarangi 0:65fd20a989e9 8 // calibrate the servos for +/-5ms over +/-45deg
csellier 1:8c1e3382b4d7 9 ServoRight.calibrate(0.0005,45);
csellier 1:8c1e3382b4d7 10 ServoLeft.calibrate(0.0005,45);
kmarangi 0:65fd20a989e9 11 }
kmarangi 0:65fd20a989e9 12 int main() {
kmarangi 0:65fd20a989e9 13
kmarangi 0:65fd20a989e9 14
kmarangi 0:65fd20a989e9 15 // set the USB serial interface baud rate
kmarangi 0:65fd20a989e9 16 pc.baud(921600);
kmarangi 0:65fd20a989e9 17
kmarangi 0:65fd20a989e9 18 init_servo();
kmarangi 0:65fd20a989e9 19
kmarangi 0:65fd20a989e9 20 while(1) {
kmarangi 0:65fd20a989e9 21
kmarangi 0:65fd20a989e9 22
kmarangi 0:65fd20a989e9 23 // sernd the servo command to the servos themselves
csellier 1:8c1e3382b4d7 24 ServoRight.write(0.6); // write to the continuous rotation servo1
csellier 1:8c1e3382b4d7 25 ServoLeft.write(0.4); // write to the continous servo2
kmarangi 0:65fd20a989e9 26
kmarangi 0:65fd20a989e9 27 }
kmarangi 0:65fd20a989e9 28 }
kmarangi 0:65fd20a989e9 29
kmarangi 0:65fd20a989e9 30