Programmation d’une serrure codée à l’aide de la carte BLUE PILL
Dependencies: mbed KeypadLib TextLCD
Revision 0:2b52d7eab29d, committed 2019-10-15
- Comitter:
- mohamedwajdi
- Date:
- Tue Oct 15 22:30:22 2019 +0000
- Commit message:
- TP2 Ex2 uC et interfaces 2GII
Changed in this revision
diff -r 000000000000 -r 2b52d7eab29d KeypadLib.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/KeypadLib.lib Tue Oct 15 22:30:22 2019 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/rlanghbv/code/KeypadLib/#1f7793af2f64
diff -r 000000000000 -r 2b52d7eab29d TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Tue Oct 15 22:30:22 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r 2b52d7eab29d main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 15 22:30:22 2019 +0000 @@ -0,0 +1,73 @@ +// programme incomplet +#include "mbed.h" +#include "keypad.h" +#include "TextLCD.h" + +DigitalOut led1(PC_14); //indique erreur du mot de passe +DigitalOut led2(PC_15); //indique ouverture de la porte +DigitalOut Gache(PB_8); +DigitalOut Buzzer(PB_9); + + // C1 C2 C3 C4 L1 L2 L3 L4 + Keypad clavier( PA_3,PA_2,PA_1,PA_0,PA_7,PA_6,PA_5,PA_4 ); + // RS E D4 D5 D6 D7 + TextLCD lcd(PA_9, PA_8, PB_15, PB_14, PB_13, PB_12,TextLCD::LCD16x2); + +#define Long_PassWord 4 // Nombre des caractère du mot de passe +#define nb_tentative 3 // Nombre des tentatives permises + +char key, compt=0,i; +char compt_nb_tentative=0; +char Password[Long_PassWord]={1,2,3,4}; + +int main() { + clavier.enablePullUp(); + lcd.cls(); + led1 = 0; + led2 = 0; + Gache = 0; + Buzzer = 0; + lcd.printf("ENETCOM Dep II TP2 uC et I 2GII"); + while (1) { + compt = 0; + for(i=0;i<Long_PassWord;i++) { + do{ + key=clavier.getKey(); + }while(key == 0); + lcd.printf("%c",key); + lcd.printf("*"); + if(Password[i]+48==key) + compt++; + wait(1); + } + if(compt==Long_PassWord) { + lcd.printf("Correct"); + led2 = 1; //indique ouverture de la porte + Gache = 1; //ouverture de la porte + wait(2); + Gache = 0; + led2 = 0; + } + else { + lcd.printf("Erreur"); + led1 = 1; //indique erreur du mot de passe + compt_nb_tentative++; + if(compt_nb_tentative==nb_tentative) { + compt_nb_tentative=0; + compt=0; + lcd.cls(); + lcd.printf("Password bloque"); + Buzzer = 1; + do{ + key=clavier.getKey(); + }while(key != '#'); + wait(1); + lcd.cls(); + } + Buzzer = 0; + led1 = 0; + + } + } +} +
diff -r 000000000000 -r 2b52d7eab29d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 15 22:30:22 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file