Fa2018-es200-3321-proj2-WHACK_A_MOLE
/
HighFiveCode
Code for the High Five Portion of the game
Fork of Guntrigger by
main.cpp@0:e65fc2ec46d6, 2018-10-10 (annotated)
- Committer:
- vinnypotente
- Date:
- Wed Oct 10 14:40:32 2018 +0000
- Revision:
- 0:e65fc2ec46d6
- Child:
- 1:a1880f0b0f04
The Code for the gun trigger
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vinnypotente | 0:e65fc2ec46d6 | 1 | #include "mbed.h" |
vinnypotente | 0:e65fc2ec46d6 | 2 | #include "Servo.h" |
vinnypotente | 0:e65fc2ec46d6 | 3 | |
vinnypotente | 0:e65fc2ec46d6 | 4 | Servo myservo(p21); |
vinnypotente | 0:e65fc2ec46d6 | 5 | float pos; |
vinnypotente | 0:e65fc2ec46d6 | 6 | char c; |
vinnypotente | 0:e65fc2ec46d6 | 7 | int main() |
vinnypotente | 0:e65fc2ec46d6 | 8 | { |
vinnypotente | 0:e65fc2ec46d6 | 9 | myservo.calibrate(0.0009,90.0); |
vinnypotente | 0:e65fc2ec46d6 | 10 | myservo=0.0; |
vinnypotente | 0:e65fc2ec46d6 | 11 | wait(1); |
vinnypotente | 0:e65fc2ec46d6 | 12 | while (1) { |
vinnypotente | 0:e65fc2ec46d6 | 13 | c = getchar (); |
vinnypotente | 0:e65fc2ec46d6 | 14 | for (pos =0.0; pos<=10.0; pos=pos+10.0) { |
vinnypotente | 0:e65fc2ec46d6 | 15 | myservo=(pos/10.0); |
vinnypotente | 0:e65fc2ec46d6 | 16 | wait (0.07); |
vinnypotente | 0:e65fc2ec46d6 | 17 | printf("%f\n",pos); |
vinnypotente | 0:e65fc2ec46d6 | 18 | } |
vinnypotente | 0:e65fc2ec46d6 | 19 | for (pos =10.0; pos>=0.0; pos=pos-10.0) { |
vinnypotente | 0:e65fc2ec46d6 | 20 | myservo=(pos/10.0); |
vinnypotente | 0:e65fc2ec46d6 | 21 | wait (0.07); |
vinnypotente | 0:e65fc2ec46d6 | 22 | printf("%f\n",pos); |
vinnypotente | 0:e65fc2ec46d6 | 23 | } |
vinnypotente | 0:e65fc2ec46d6 | 24 | } |
vinnypotente | 0:e65fc2ec46d6 | 25 | } |