Hardware components | ||||||
![]() |
| × | 1 | |||
| × | 1 | ||||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
ProjectNameis Charge Mobile using timer
In this project I have make the mobile charger using timer in particular time.When user set particular time. If time is complete then It is automatically OFF the mobile charging.
Also I have add in new concept. In this concept When timer is set suddenly power supply is OFF and after sometime power supply is ON then it is automatically start charging from remaining time and when time is complete then automatically stop mobile charging. In this concept use EEPROM.
In project also set the time limit 3 hours only when user set above 3 hours then it is display the message time limit only 3 hours.
I have face problem in night. Also When busy in work that is I have decide to make it.
Advantages:-
1)To charge mobile in particular time.
2)To reduce battery loss.
3) To used EEPROM concept for to remember the time when suddenly power supply is OFF.
you will add future scope for to charge mobile fast or increase speed of charging.
#include <LiquidCrystal.h>
#include<EEPROM.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int a=0,b=0;
void timer();
void checked();
int S;
int check;
int value;
int M;
int H;
int pin=3;
int valueM;
int valueS;
int valueH;
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5
int read_LCD_buttons()
{
adc_key_in = analogRead(0);
value=adc_key_in;
EEPROM.update(0,value);
if (adc_key_in > 1500) return btnNONE;
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 500) return btnLEFT;
if (adc_key_in < 700) return btnSELECT;
return btnNONE;
}
void setup()
{
lcd.begin(16, 2);
pinMode(pin,OUTPUT);
digitalWrite(pin,check);
Serial.begin(9600);
checked();
}
void loop()
{
lcd.setCursor(1,0);
lcd.print ("Set the timer");
lcd.setCursor(0,1);
lcd_key = read_LCD_buttons();
switch (lcd_key)
{
case btnUP: //for minute increment
{
lcd.setCursor(1,0);
lcd.print ("Set the timer");
lcd.setCursor(6,1);
lcd.print(":");
lcd.setCursor(9,1);
lcd.print(":");
if(b<4)
{
if(a>9){
if(a<=59){
lcd.setCursor(7,1);
lcd.print(a);
a++;
Serial.println(a);
if(a==60){
a=0;
}
}
}
else{
lcd.setCursor(7,1);
lcd.print("0");
lcd.setCursor(8,1);
lcd.print(a);
a++;
Serial.println(a);
}
delay(500);
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("timer is limited");
lcd.setCursor(2,1);
lcd.print("for 3 hours");
delay(2000);
lcd.clear();
a=0;
b=0;
}
break;
}
case btnLEFT: //for hours
{
lcd.setCursor(1,0);
lcd.print ("Set the timer");
lcd.setCursor(6,1);
lcd.print(":");
lcd.setCursor(9,1);
lcd.print(":");
if(b<4){
lcd.setCursor(4,1);
lcd.print("0");
lcd.setCursor(5,1);
lcd.print(b);
b++;
}
else{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("timer is limited");
lcd.setCursor(2,1);
lcd.print("for 3 hours");
delay(2000);
lcd.clear();
lcd.setCursor(1,0);
lcd.print ("Set the timer");
lcd.setCursor(6,1);
lcd.print(":");
lcd.setCursor(9,1);
lcd.print(":");
b=0;
}
delay(500);
break;
}
case btnSELECT: // statring the timer
{
if(b==4 && (a>0 && a<59))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("timer is limited");
lcd.setCursor(2,1);
lcd.print("for 3 hours");
delay(2000);
lcd.clear();
a=0;
b=0;
}
else{
timer();
}
break;
}
}
}
//timer code
void timer(){
int S=59;
lcd.clear();
M=a-2;
H=b-1;
while(1){
EEPROM.write(104,M);
valueM=EEPROM.read(104);
EEPROM.update(1,valueM);
Serial.print(valueM);
EEPROM.write(103,S);
valueS=EEPROM.read(103);
EEPROM.update(0,valueS);
Serial.print(valueS);
EEPROM.write(105,H);
valueH=EEPROM.read(105);
Serial.print(valueH);
EEPROM.update(3,H);
lcd.setCursor(3,0);
lcd.print ("timer set");
lcd.setCursor(12,0);
lcd.setCursor(6,1);
lcd.print(":");
lcd.setCursor(9,1);
lcd.print(":");
S--;
delay(1000);
int y= analogRead(0); ///used for reset button
if(y<700){
digitalWrite(pin,LOW);
EEPROM.write(S,0);
EEPROM.write(M,0);
EEPROM.write(H,0);
lcd.setCursor(3,0);
lcd.print ("timer set");
lcd.setCursor(12,0);
lcd.setCursor(4,1);
lcd.print(" ");
lcd.setCursor(6,1);
lcd.print(":");
lcd.setCursor(7,1);
lcd.print(" ");
lcd.setCursor(9,1);
lcd.print(":");
lcd.setCursor(10,1);
lcd.print(" ");
return loop();
}
digitalWrite(pin,check);
EEPROM.update(1,check);
digitalWrite(pin,HIGH);
if(S<0)
{
M--;
S=59;
}
if(M<0)
{
H--;
M=59;
}
if(H<0)
{
H=23;
M=59;
S=59;
digitalWrite(pin,check);
EEPROM.update(0,check);
lcd.clear();
lcd.setCursor(2,1);
lcd.print("timer is end");
EEPROM.write(S,0);
EEPROM.write(M,0);
EEPROM.write(H,0);
lcd.setCursor(3,0);
delay(1000);
lcd.clear();
exit(0);
}
if(M>9)
{
lcd.setCursor(7,1);
lcd.print(M);
}
else
{
lcd.setCursor(7,1);
lcd.print("0");
lcd.setCursor(8,1);
lcd.print(M);
lcd.setCursor(9,1);
lcd.print(":");
}
if(S>9)
{
lcd.setCursor(10,1);
lcd.print(S);
}
else
{
lcd.setCursor(10,1);
lcd.print("0");
lcd.setCursor(11,1);
lcd.print(S);
lcd.setCursor(12,1);
lcd.print(" ");
}
if(H>9)
{
lcd.setCursor(4,1);
lcd.print (H);
}
else
{
lcd.setCursor(4,1);
lcd.print("0");
lcd.setCursor(5,1);
lcd.print(H);
lcd.setCursor(6,1);
lcd.print(":");
}
}
}
///checked
void checked()
{
if(check==0)
{
lcd.clear();
valueS=EEPROM.read(103);
Serial.print(valueS);
valueM=EEPROM.read(104);
Serial.print(valueM);
valueH=EEPROM.read(105);
Serial.print(valueH);
S=valueS;
M=valueM;
H=valueH;
while(1){
EEPROM.write(104,M);
valueM=EEPROM.read(104);
EEPROM.update(1,valueM);
Serial.print(valueM);
EEPROM.write(103,S);
valueS=EEPROM.read(103);
EEPROM.update(0,valueS);
Serial.print(valueS);
EEPROM.write(105,H);
valueH=EEPROM.read(105);
Serial.print(valueH);
EEPROM.update(3,H);
lcd.setCursor(3,0);
lcd.print ("timer set");
lcd.setCursor(12,0);
lcd.setCursor(6,1);
lcd.print(":");
lcd.setCursor(9,1);
lcd.print(":");
S--;
delay(1000);
int x= analogRead(0);
if(x<700)
{
digitalWrite(pin,LOW);
EEPROM.write(S,0);
EEPROM.write(M,0);
EEPROM.write(H,0);
lcd.setCursor(3,0);
lcd.setCursor(3,0);
lcd.print ("timer set");
lcd.setCursor(12,0);
lcd.setCursor(4,1);
lcd.print(" ");
lcd.setCursor(6,1);
lcd.print(":");
lcd.setCursor(7,1);
lcd.print(" ");
lcd.setCursor(9,1);
lcd.print(":");
lcd.setCursor(10,1);
lcd.print(" ");
return loop();
}
digitalWrite(pin,HIGH);
if(S<0)
{
M--;
S=59;
}
if(M<0)
{
H--;
M=59;
}
if(H<0)
{
H=23;
M=59;
S=59;
digitalWrite(pin,LOW);
lcd.clear();
lcd.setCursor(2,1);
lcd.print("timer is end");
delay(1000);
EEPROM.write(S,0);
EEPROM.write(M,0);
EEPROM.write(H,0);
lcd.setCursor(3,0);
lcd.clear();
return loop();
}
if(M>9)
{
lcd.setCursor(7,1);
lcd.print(M);
}
else
{
lcd.setCursor(7,1);
lcd.print("0");
lcd.setCursor(8,1);
lcd.print(M);
lcd.setCursor(9,1);
lcd.print(":");
}
if(S>9)
{
lcd.setCursor(10,1);
lcd.print(S);
}
else
{
lcd.setCursor(10,1);
lcd.print("0");
lcd.setCursor(11,1);
lcd.print(S);
lcd.setCursor(12,1);
lcd.print(" ");
}
if(H>9)
{
lcd.setCursor(4,1);
lcd.print (H);
}
else
{
lcd.setCursor(4,1);
lcd.print("0");
lcd.setCursor(5,1);
lcd.print(H);
lcd.setCursor(6,1);
lcd.print(":");
}
}
}
else if(check==1)
{
Serial.print("OFF");
return loop();
}
}






_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)




Comments