![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Code for the High Five Portion of the game
Fork of Guntrigger by
main.cpp@2:629e8eb2c308, 2018-10-15 (annotated)
- Committer:
- vinnypotente
- Date:
- Mon Oct 15 13:55:27 2018 +0000
- Revision:
- 2:629e8eb2c308
- Parent:
- 1:a1880f0b0f04
added the comments
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 | 2:629e8eb2c308 | 3 | |
vinnypotente | 2:629e8eb2c308 | 4 | Servo myservo(p22); |
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 | 2:629e8eb2c308 | 14 | for (pos =0.0; pos<=40.0; pos=pos+10.0) { |
vinnypotente | 2:629e8eb2c308 | 15 | myservo=(pos/90.0); |
vinnypotente | 0:e65fc2ec46d6 | 16 | wait (0.07); |
vinnypotente | 0:e65fc2ec46d6 | 17 | printf("%f\n",pos); |
vinnypotente | 0:e65fc2ec46d6 | 18 | } |
vinnypotente | 2:629e8eb2c308 | 19 | wait(1.0); //shows the hand |
vinnypotente | 2:629e8eb2c308 | 20 | for (pos =40.0; pos>=60.0; pos=pos+10.0) { |
vinnypotente | 2:629e8eb2c308 | 21 | myservo=(pos/90.0); |
vinnypotente | 2:629e8eb2c308 | 22 | wait (0.07); |
vinnypotente | 2:629e8eb2c308 | 23 | printf("%f\n",pos); |
vinnypotente | 2:629e8eb2c308 | 24 | } |
vinnypotente | 2:629e8eb2c308 | 25 | wait (1.0); // moves hand forward to hit users hand |
vinnypotente | 2:629e8eb2c308 | 26 | for (pos =60.0; pos>=0.0; pos=pos-10.0) { |
vinnypotente | 2:629e8eb2c308 | 27 | myservo=(pos/90.0); |
vinnypotente | 0:e65fc2ec46d6 | 28 | wait (0.07); |
vinnypotente | 0:e65fc2ec46d6 | 29 | printf("%f\n",pos); |
vinnypotente | 0:e65fc2ec46d6 | 30 | } |
vinnypotente | 0:e65fc2ec46d6 | 31 | } |
vinnypotente | 0:e65fc2ec46d6 | 32 | } |