Created
March 29, 2016 10:21
-
-
Save elktros/f0650545297342ffccbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LiquidCrystal.h> | |
LiquidCrystal lcd(7,6,5,4,3,2); | |
const int set = 8; | |
int hours=10; | |
int start=11; | |
int relay=9; | |
int b=0,h=0,t=0; | |
int buttonState = 0; | |
int lastButtonState = 0; | |
void setup() { | |
pinMode(set,INPUT); | |
pinMode(hours,INPUT); | |
pinMode(relay,OUTPUT); | |
pinMode(start,INPUT); | |
lcd.begin(16,2); | |
lcd.setCursor(0,0); | |
lcd.print("Adjustable Timer"); | |
} | |
int timer( int b,int h) | |
{ | |
if(b<=9) | |
{ | |
lcd.setCursor(3,1); | |
lcd.print(0); | |
lcd.setCursor(4,1); | |
lcd.print(b); | |
} | |
else{lcd.setCursor(3,1);lcd.print(b);} | |
lcd.setCursor(2,1); | |
lcd.print(":"); | |
if(h<=9) | |
{ | |
lcd.setCursor(0,1); | |
lcd.print(0); | |
lcd.setCursor(1,1); | |
lcd.print(h); | |
} | |
else{lcd.setCursor(0,1);lcd.print(h);} | |
} | |
void loop() | |
{ | |
buttonState = digitalRead(set); | |
if (buttonState != lastButtonState) | |
{ | |
if(buttonState == HIGH) | |
{ | |
lcd.clear(); | |
lcd.print("Set time in min:"); | |
++b; | |
timer(b,h); | |
} | |
lastButtonState = buttonState; | |
} | |
if (digitalRead(hours)== HIGH) | |
{ | |
lcd.clear(); | |
lcd.print("Set time in hours"); | |
++h; | |
timer(b,h); | |
while(digitalRead(hours)==HIGH); | |
} | |
if(digitalRead(start)==HIGH) | |
{ | |
lcd.clear(); | |
t=((h*60)+(b))*1000; | |
lcd.print("Timer is set for"); | |
timer(b,h); | |
digitalWrite(relay,HIGH); | |
delay(t); | |
digitalWrite(relay,LOW); | |
while(digitalRead(start) == HIGH ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment