Contest IOT GSE5
/
contest_IOT4
Pong Game Tea Term
Fork of contest_IOT3 by
Revision 6:89a007f6508f, committed 2015-11-04
- Comitter:
- Alex_Hochart
- Date:
- Wed Nov 04 11:57:48 2015 +0000
- Parent:
- 5:9437083564d0
- Commit message:
- pong3
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9437083564d0 -r 89a007f6508f main.cpp --- a/main.cpp Tue Nov 03 11:55:50 2015 +0000 +++ b/main.cpp Wed Nov 04 11:57:48 2015 +0000 @@ -2,12 +2,12 @@ #include "HCSR04.h" #include <math.h> -#define ECHO_1 PA_8 -#define ECHO_2 PB_4 -#define TRIG_1 PB_10 -#define TRIG_2 PB_5 -#define PUSH USER_BUTTON //PC_13 -#define LED_1 LED1 +#define ECHO_1 PA_4 +#define ECHO_2 PB_3 +#define TRIG_1 PB_5 +#define TRIG_2 PA_10 +#define PUSH PA_9 //PC_13 +#define LED_1 PA_8 //------------------------------------ // Hyperterminal configuration @@ -17,7 +17,7 @@ Serial pc(USBTX, USBRX); //UART DigitalOut led(LED_1); //Led d'état -DigitalIn bp(USER_BUTTON); +DigitalIn bp(PUSH); HCSR04 sensor1(TRIG_1, ECHO_1); HCSR04 sensor2(TRIG_2, ECHO_2); @@ -102,7 +102,6 @@ *angBall = 180 - *angBall; } else{ return 2; } - } } @@ -144,16 +143,19 @@ p2_score = 0; wait(1); led=1; + wait(1); //Initialisation de l'interruption : en appuyant sur le bouton bleu de la carte, le programme change d'état //Boucle d'exécution du programme while(1) { switch(state){ - case 0 : if(bp.read() != 1){ + case 0 : if(bp.read() == 1){ state = 3; pong_init_ttempro(); + led = 1; } + else led = 0; break; case 3 : for(int i=0; i<=29; i++){ @@ -162,8 +164,8 @@ pos1[i]= 0; pos2[i]= 0; } - distance1 = 22;//sensor1.distance(1); - distance2 = 10;//sensor2.distance(1); + distance1 = sensor1.distance(1); + distance2 = sensor2.distance(1); set_pos_vector(pos1,distance1); set_pos_vector(pos2,distance2); print_cursor_ttempro(pos1,pos1prec,pos2,pos2prec);