A

Dependencies:   mbed Servo KeypadLib TextLCD

Files at this revision

API Documentation at this revision

Comitter:
Virgi97
Date:
Thu Dec 06 11:24:46 2018 +0000
Parent:
2:74c155c71eb5
Commit message:
A

Changed in this revision

Cassaforte.cpp Show annotated file Show diff for this revision Revisions of this file
KeypadLib.lib 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/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
--- a/KeypadLib.lib	Wed Dec 05 20:25:42 2018 +0000
+++ b/KeypadLib.lib	Thu Dec 06 11:24:46 2018 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/rlanghbv/code/KeypadLib/#1f7793af2f64
+http://developer.mbed.org/users/rlanghbv/code/KeypadLib/#fb28bc08ded4
--- a/main.cpp	Wed Dec 05 20:25:42 2018 +0000
+++ b/main.cpp	Thu Dec 06 11:24:46 2018 +0000
@@ -1,3 +1,24 @@
+/*      *PINOUT E CABLAGGIO
+        *5V ---> VCC MODULO I2C DISPLAY;
+        *GND ---> VCC MODULO I2C DISPLAY, CATODI LED, BUZZER-PIEZO;
+        *PIN D15 ---> SCL MODULO I2C DISPLAY;
+        *PIN D14 ---> SDA MODULO I2C DISPLAY;
+        *PIN D13 ---> LED VERDE;
+        *PIN D12 ---> LED ROSSO;
+        *PIN D11 ---> SERVO;
+        *PIN D10 ---> PIN 1 TASTIERINO;
+        *PIN D9 ---> PIN 2 TASTIERINO;
+        *PIN D8 ---> PIN 3 TASTIERINO;
+        *PIN D7 ---> PIN 4 TASTIERINO;
+        *PIN D6 ---> PIN 5 TASTIERINO;
+        *PIN D5 ---> PIN 6 TASTIERINO;
+        *PIN D4 ---> PIN 7 TASTIERINO;
+        *PIN D3 ---> PIN 8 TASTIERINO;
+        *PIN D2 ---> INTERRUTTORE MAGNETICO;
+        *PIN PC_10 ---> BUZZER-PIEZO;
+        
+*/
+
 #include "Cassaforte.h"
 #include "mbed.h"
 //#include <TextLCD.h>
@@ -7,13 +28,16 @@
 void scrivi(char parola[]);
 void cambioCodice();
 void inserisci();*/
-InterruptIn button(PC_13);
+InterruptIn alarm(PC_13);
+bool avvio = true;
 char v[4];
 int cont2;
 int main() {
-    /*lcd.setMode(TextLCD_I2C::DispOn);
-    lcd.setCursor(TextLCD_I2C::CurOn_BlkOn);*/
+    alarm.rise(&allarme);
+    if (avvio == true){
     inizializza();
+    avvio = false;
+    }
     cont2=0;
     do{
     scrivi("Immetti codice:");