project2
Dependencies: Motor Servo mbed
Diff: main.cpp
- Revision:
- 2:61a0c2d9be75
- Parent:
- 1:23be1a2c3357
--- a/main.cpp Fri Oct 16 00:44:51 2015 +0000 +++ b/main.cpp Fri Oct 16 01:12:52 2015 +0000 @@ -5,7 +5,7 @@ #include "stdlib.h" #include "stdio.h" -BusIn switches(p19, p18, p17, p16); +DigitalIn switches[4]= {p19, p18, p17, p16}; Motor m(p25, p27, p28); Servo servo_1(p); Servo servo_2(p); @@ -13,17 +13,37 @@ servo_2.calibrate(.0009, 90); float a; float b; +char j; +char l; +char s; +char f; -int main(void) { +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) { + printf(" Tap "j" to move your character left. Tap "l" to move your character right\n\r"); + scanf("%c", &j); + scanf("%c", &l); + if ( ) { + + servo_1 = .66; + wait(.75); + servo_1 = .5; + } + wait (.75); + if ( ) { + + servo_1= .33; + wait (.75); + servo_1 = .5; + } a = rand()/(float)RAND_MAX*(-2.0)+1.0; - b = rand()/(float)RAND_MAX*5.0 +10.0; + b = rand()/(float)RAND_MAX*5.0 +10.0; servo_2 = .6; m.speed(a) - - - \ No newline at end of file + +