A
Dependencies: mbed Servo KeypadLib TextLCD
Diff: Cassaforte.cpp
- Revision:
- 3:c64c5ac14d22
- Parent:
- 2:74c155c71eb5
diff -r 74c155c71eb5 -r c64c5ac14d22 Cassaforte.cpp --- a/Cassaforte.cpp Wed Dec 05 20:25:42 2018 +0000 +++ b/Cassaforte.cpp Thu Dec 06 11:24:46 2018 +0000 @@ -3,20 +3,24 @@ #include "Servo.h" #include "keypad.h" I2C i2c(D14, D15); -TextLCD_I2C lcd(&i2c, 0x4E, TextLCD_I2C::LCD16x2, TextLCD_I2C::HD44780); -DigitalOut led(LED1); -Servo servo(D11); -int dim=4; +TextLCD_I2C lcd(&i2c, 0x4E, TextLCD_I2C::LCD16x2, TextLCD_I2C::HD44780); //comunicazione Nucleo-display Keypad keypad(D6,D5,D4,D3,D10,D9,D8,D7); //porte del tastierino +Servo servo(D11); //porta servo +DigitalOut led_verde(D13); //led apertura +DigitalOut led_rosso(D12); // led chiusura +DigitalOut buz(PC_10); //porta buz +DigitalIn mag(PC_13); //porta del magnete +int dim=4; char pass[4]={'1','2','3','4'};//password di default (è possibile cambiarla dal menu) -DigitalOut buz(D2); -//porta buz -DigitalIn mag(D1); //porta del magnete bool alonoff=true; //variabile booleana per abilitare o disabilitare l'allarme in caso di apertura e chiusura (?) void inizializza(){ lcd.setMode(TextLCD_I2C::DispOn); buz=0; + if(mag == 1){ + chiuso(); + //wait(0.3); + } else aperto(); //lcd.setCursor(TextLCD_I2C::CurOn_BlkOn); } @@ -26,13 +30,17 @@ } void chiuso(){ - servo.position(-90); - + servo.position(90); + wait(0.3); + led_rosso = 1; + led_verde = 0; } void aperto(){ servo.position(-90); - + wait(0.3); + led_rosso = 0; + led_verde = 1; } void inserimento(char a[],int n,bool vis){ int i=0; @@ -87,7 +95,7 @@ scrivi("Apertura..."); alonoff=false; aperto(); - wait(2); + wait(0.3); //2 menu(); // } } @@ -96,7 +104,7 @@ scrivi("Chiusura..."); alonoff=true; chiuso(); - wait(2); + wait(0.3); //2 main(); } } @@ -128,8 +136,7 @@ } } void allarme(){ - - char insa[4]; + char insa[4]; do{ buz=1; scrivi(" Allarme!"); @@ -139,7 +146,6 @@ buz=0; menu(); } - }while(1); } \ No newline at end of file