LCD, Servo....

Dependencies:   mbed Servo TextLCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Cassaforte.cpp Source File

Cassaforte.cpp

00001 #include "Cassaforte.h"
00002 #include "TextLCD.h"
00003 #include "Servo.h"
00004 I2C i2c(D14, D15);
00005 //InterruptIn button(PC_13);
00006 TextLCD_I2C lcd(&i2c, 0x4E, TextLCD_I2C::LCD16x2, TextLCD_I2C::HD44780);
00007 DigitalOut led(LED1);
00008 Servo servo(D3);
00009 bool sensore = false;
00010 
00011 void inizializza(){
00012     lcd.setMode(TextLCD_I2C::DispOn);
00013     lcd.setCursor(TextLCD_I2C::CurOn_BlkOn);
00014     if (sensore == true)
00015         chiuso();
00016         else aperto();
00017     }
00018 
00019 void scrivi(char parola[]){
00020     lcd.cls();
00021     lcd.printf("%s\n", parola);
00022     }
00023     
00024 void cambioCodice(){
00025     led=!led;
00026     scrivi("Cambio codice   di apertura");
00027     lcd.setAddress(11,1);
00028     wait(3);
00029     lcd.cls();
00030     scrivi("Digitare il nuo_vo codice:");
00031     lcd.setAddress(10,1);
00032     inserimento();
00033     led=!led;
00034     }
00035     
00036 void inserimento(){
00037         /*for (int i=0; i<4; i++){
00038             wait(1);
00039             lcd.putc(i);
00040             wait(1);
00041             lcd.setAddress(11+i,1);
00042             }*/
00043         wait(1);
00044         lcd.putc('1');
00045         wait(1);
00046         lcd.setAddress(11,1);
00047         lcd.putc('2');
00048         wait(1);
00049         lcd.setAddress(12,1);
00050         lcd.putc('3');
00051         wait(1);
00052         lcd.setAddress(13,1);
00053         lcd.putc('4');
00054         wait(1); 
00055     }
00056     
00057 void chiuso(){
00058     servo.position(-90);
00059     
00060     }
00061     
00062 void aperto(){
00063     servo.position(-90);
00064     
00065     }