project2
Dependencies: Motor Servo mbed
main.cpp
- Committer:
- thetstone
- Date:
- 2015-10-16
- Revision:
- 1:23be1a2c3357
- Parent:
- 0:be1f12b9b509
- Child:
- 2:61a0c2d9be75
File content as of revision 1:23be1a2c3357:
#include "mbed.h" #include "Motor.h" #include "Servo.h" #include "math.h" #include "stdlib.h" #include "stdio.h" BusIn switches(p19, p18, p17, p16); Motor m(p25, p27, p28); Servo servo_1(p); Servo servo_2(p); servo_1.calibrate(.0009,90); servo_2.calibrate(.0009, 90); float a; float b; int main(void) { servo_1 = .5; servo_2 = .5; a = rand()/(float)RAND_MAX*(-2.0)+1.0; b = rand()/(float)RAND_MAX*5.0 +10.0; if ( switches== 1) { a = rand()/(float)RAND_MAX*(-2.0)+1.0; b = rand()/(float)RAND_MAX*5.0 +10.0; servo_2 = .6; m.speed(a)