Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DigitCode by
Revision 1:0f2ba28c2e70, committed 2015-04-14
- Comitter:
- Ridaz
- Date:
- Tue Apr 14 08:42:37 2015 +0000
- Parent:
- 0:163dfb02ed36
- Child:
- 2:03518f08ccc0
- Commit message:
- ;
Changed in this revision
| fonction.h | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/fonction.h Tue Apr 14 08:34:05 2015 +0000 +++ b/fonction.h Tue Apr 14 08:42:37 2015 +0000 @@ -3,6 +3,7 @@ #define NB2 2 #define NB3 3 #define FINAL 4 +#define ERREUR 5 int bitToInt(int );
--- a/main.cpp Tue Apr 14 08:34:05 2015 +0000
+++ b/main.cpp Tue Apr 14 08:42:37 2015 +0000
@@ -2,6 +2,7 @@
#include "fonction.h"
DigitalOut myled(LED1);
DigitalOut myled2(LED4);
+DigitalOut myled3(LED3);
BusIn bus(p19, p18,p17,p16,p15,p14,p13,p12,p11,p10,p9,p8);
int etat = 0;
int code[] = {1, 2, 3, 4};
@@ -15,21 +16,26 @@
n = bitToInt(n);
switch (etat) {
case ETAT0:
+ myled = 1;
+ myled2 = 0;
+ myled3 = 0;
if (n == code[0] && nPrecedent == -3 ) {
etat = NB1;
- myled = 1;
- myled2 = 0;
+
wait(0.2);
}
break;
case NB1:
+ myled = 0;
+ myled2 = 0;
+ myled3 = 0;
if (n == code[1] && nPrecedent == -3) {
etat = NB2;
myled = 0;
wait(0.2);
} else if (n != -3)
- etat = ETAT0;
+ etat = ERREUR;
break;
case NB2:
@@ -39,7 +45,7 @@
}
else if (n != -3)
- etat = ETAT0;
+ etat = ERREUR;
break;
case NB3:
@@ -47,7 +53,7 @@
etat = FINAL;
wait(0.2);
} else if (n != -3)
- etat = ETAT0;
+ etat = ERREUR;
break;
case FINAL:
@@ -55,7 +61,11 @@
myled2 = 1;
wait(5);
break;
-
+ case ERREUR:
+ myled3 = 1;
+ wait(1);
+ myled2 = 0;
+ etat = ETAT0;
}
printf("etat = %d | n = %d | nPrecedent = %d\n", etat, n, nPrecedent);
}
