stuff
Dependencies: mbed Servo Motor
confetti.cpp
- Committer:
- m226072
- Date:
- 2019-10-15
- Revision:
- 3:e3b0e591e976
- Parent:
- 2:5b599e8e7e8c
- Child:
- 4:439279a72ef4
File content as of revision 3:e3b0e591e976:
#include "mbed.h" #include "Motor.h" #include "Servo.h" DigitalIn switches [5] = {p15, p16, p17, p18, p19}; Servo gun (p24); Servo spin (p23); Motor jeff (p26, p29, p30); int h [5]; float i; int main () { i=0.5; while (1) { h [0] = switches [0]; h [1] = switches [1]; h [2] = switches [2]; h [3] = switches [3]; h [4] = switches [4]; // switch 1 on and 2 off if ((h [0] == 1) && (h [1] ==0)) { jeff.speed (0.5); } // switch 1 off and 2 on if ((h [0] == 0) && (h [1] == 1)) { jeff.speed (-0.5); } // switch 1 off and 2 off if (((h [0] == 0) && (h [1] == 0)) || ((h [0] == 1) && (h [1] == 1)) ){ jeff.speed (0); } // switch 3 on and 4 off if ((h [2] == 1) && (h [3] ==0)) { if (i>1.0) { i=1.0; } spin = i; wait (0.1); i = i + 0.02; } // switch 3 off and 4 on if ((h [2] == 0) && (h [3] ==1)) { if (i<0.0) { i=0.0; } spin = i; wait (0.1); i = i - 0.02; } // switch 3 off and 4 off if (((h [2] == 0) && (h [3] ==0))|| ((h [2] == 1) && (h [3] ==1))) { spin = i ; } // switch 5 on if (h [4] == 1) { gun = 1.0; wait (1.0); gun = 0.0; wait (1.0); } } }