project2
Dependencies: Motor Servo mbed
main.cpp@1:23be1a2c3357, 2015-10-16 (annotated)
- Committer:
- thetstone
- Date:
- Fri Oct 16 00:44:51 2015 +0000
- Revision:
- 1:23be1a2c3357
- Parent:
- 0:be1f12b9b509
- Child:
- 2:61a0c2d9be75
112
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thetstone | 0:be1f12b9b509 | 1 | #include "mbed.h" |
thetstone | 0:be1f12b9b509 | 2 | #include "Motor.h" |
thetstone | 0:be1f12b9b509 | 3 | #include "Servo.h" |
thetstone | 0:be1f12b9b509 | 4 | #include "math.h" |
thetstone | 0:be1f12b9b509 | 5 | #include "stdlib.h" |
thetstone | 0:be1f12b9b509 | 6 | #include "stdio.h" |
thetstone | 0:be1f12b9b509 | 7 | |
thetstone | 0:be1f12b9b509 | 8 | BusIn switches(p19, p18, p17, p16); |
thetstone | 0:be1f12b9b509 | 9 | Motor m(p25, p27, p28); |
thetstone | 0:be1f12b9b509 | 10 | Servo servo_1(p); |
thetstone | 0:be1f12b9b509 | 11 | Servo servo_2(p); |
thetstone | 0:be1f12b9b509 | 12 | servo_1.calibrate(.0009,90); |
thetstone | 0:be1f12b9b509 | 13 | servo_2.calibrate(.0009, 90); |
thetstone | 0:be1f12b9b509 | 14 | float a; |
thetstone | 0:be1f12b9b509 | 15 | float b; |
thetstone | 0:be1f12b9b509 | 16 | |
thetstone | 0:be1f12b9b509 | 17 | int main(void) { |
thetstone | 0:be1f12b9b509 | 18 | servo_1 = .5; |
thetstone | 0:be1f12b9b509 | 19 | servo_2 = .5; |
thetstone | 1:23be1a2c3357 | 20 | a = rand()/(float)RAND_MAX*(-2.0)+1.0; |
thetstone | 1:23be1a2c3357 | 21 | b = rand()/(float)RAND_MAX*5.0 +10.0; |
thetstone | 0:be1f12b9b509 | 22 | if ( switches== 1) { |
thetstone | 1:23be1a2c3357 | 23 | a = rand()/(float)RAND_MAX*(-2.0)+1.0; |
thetstone | 1:23be1a2c3357 | 24 | b = rand()/(float)RAND_MAX*5.0 +10.0; |
thetstone | 0:be1f12b9b509 | 25 | servo_2 = .6; |
thetstone | 1:23be1a2c3357 | 26 | m.speed(a) |
thetstone | 1:23be1a2c3357 | 27 | |
thetstone | 1:23be1a2c3357 | 28 | |
thetstone | 0:be1f12b9b509 | 29 |