Devices & Components
Arduino Uno Rev3
Alphanumeric LCD, 16 x 2
5 mm LED: Red
Buzzer, Piezo
Hardware & Tools
Breadboard, 270 Pin
Software & Tools
Arduino IDE
Project description
Code
program for lock-unlock indication using arduino
c_cpp
the program is to use arduino to indicate device is locked or unlocked
1#include <LiquidCrystal.h> 2 3// initialize the library with the numbers 4 of the interface pins 5LiquidCrystal lcd(8,9,10,11,12,13); 6int new_input_state,old_input_state=LOW; 7void 8 setup() 9{ 10 lcd.begin(16, 2); // set up the LCD's number of columns and rows: 11 12 pinMode(2,INPUT); 13 pinMode(3,OUTPUT); 14 digitalWrite(3,LOW); 15 lcd.clear(); 16 17 lcd.print("door is locked"); 18 lcd.setCursor(0,1); 19 lcd.print("properly"); 20} 21 22void 23 loop() 24{ 25 new_input_state = digitalRead(2); 26 if(new_input_state!=old_input_state) 27 28 { 29 if(new_input_state==HIGH) 30 { 31 lcd.clear(); 32 33 lcd.print("door is not"); 34 lcd.setCursor(0,1); 35 lcd.print("properly 36 locked"); 37 digitalWrite(3,HIGH); 38 tone(4,1000,2000); 39 40 } 41 else 42 { 43 lcd.clear(); 44 lcd.print("door 45 is locked"); 46 lcd.setCursor(0,1); 47 lcd.print("properly"); 48 49 digitalWrite(3,LOW); 50 noTone(4); 51 } 52 53 } 54 old_input_state = new_input_state; 55 delay(100); 56 } 57 58
program for lock-unlock indication using arduino
c_cpp
the program is to use arduino to indicate device is locked or unlocked
1#include <LiquidCrystal.h> 2 3// initialize the library with the numbers of the interface pins 4LiquidCrystal lcd(8,9,10,11,12,13); 5int new_input_state,old_input_state=LOW; 6void setup() 7{ 8 lcd.begin(16, 2); // set up the LCD's number of columns and rows: 9 pinMode(2,INPUT); 10 pinMode(3,OUTPUT); 11 digitalWrite(3,LOW); 12 lcd.clear(); 13 lcd.print("door is locked"); 14 lcd.setCursor(0,1); 15 lcd.print("properly"); 16} 17 18void loop() 19{ 20 new_input_state = digitalRead(2); 21 if(new_input_state!=old_input_state) 22 { 23 if(new_input_state==HIGH) 24 { 25 lcd.clear(); 26 lcd.print("door is not"); 27 lcd.setCursor(0,1); 28 lcd.print("properly locked"); 29 digitalWrite(3,HIGH); 30 tone(4,1000,2000); 31 } 32 else 33 { 34 lcd.clear(); 35 lcd.print("door is locked"); 36 lcd.setCursor(0,1); 37 lcd.print("properly"); 38 digitalWrite(3,LOW); 39 noTone(4); 40 } 41 } 42 old_input_state = new_input_state; 43 delay(100); 44 } 45
Downloadable files
arduino lock-unlock indicator circuit
arduino is used to indicate either door/locker/drawer/device is properly locked or not
arduino lock-unlock indicator circuit

Comments
Only logged in users can leave comments