robogamishivanshsumitbranfigo
Created December 27, 2020 © GPL3+

Hello Digital Timer

Hello Digital Timer for turning any device on for a set duration.

IntermediateFull instructions provided94
Hello Digital Timer

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Alphanumeric LCD, 16 x 2
Alphanumeric LCD, 16 x 2
×2
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×3
Buzzer
Buzzer
×1
Resistor 220 ohm
Resistor 220 ohm
×2
Jumper wires (generic)
Jumper wires (generic)
×50
Slide Switch
Slide Switch
×1
Breadboard (generic)
Breadboard (generic)
×1
DC Motor, Miniature
DC Motor, Miniature
×1
LED Light Bulb, Cool White
LED Light Bulb, Cool White
×1
Solid State Relay
Solid State Relay
×1

Software apps and online services

Arduino IDE
Arduino IDE
Tinkercad
Autodesk Tinkercad

Story

Read more

Schematics

Initial state of the project

When the timer is on

When the duration time is on.

Code

Untitled file

C/C++
#include <LiquidCrystal.h>
LiquidCrystal lcd1(13, 12, 11, 10, 9, 8);
LiquidCrystal lcd2(7, 6, 5, 4, 3, 2);
int push_button = A0; // select the input pin for switch
int minutes;
int seconds;
int updated_minutes;
int updated_seconds;
int button = 0; // variable to store the value coming from the sensor
int timer_time;
int duration;
void setup()
{
Serial.begin(9600);  
lcd1.begin(16, 2);
lcd2.begin(16, 2);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);  
pinMode(push_button, INPUT);
pinMode(A1, INPUT); 
pinMode(A2, INPUT);  
}

void loop()
{ 
digitalWrite(A3,LOW);
digitalWrite(A4,LOW);  
button = digitalRead(push_button);
timer_time = analogRead(A1); 
timer_time = timer_time/20;  
duration = analogRead(A2);
duration = duration/20;  
Serial.print("Timer time = ");
Serial.println(timer_time); 
Serial.print("Duration = ");
Serial.println(duration);  
lcd2.setCursor(0,0);
lcd2.print("Timer Time ");
lcd2.setCursor(13,0);
lcd2.print(timer_time);  
lcd2.setCursor(0,1);
lcd2.print("Duration ");
lcd2.setCursor(13,1);
lcd2.print(duration); 
delay(400);
lcd2.clear();  
  if(button == HIGH )
  {
    digitalWrite(A4, HIGH); 
  for(minutes=0;minutes<timer_time;minutes++)
  {
    lcd1.setCursor(0,0);
    lcd1.print("My Timer:-   ");
    lcd1.setCursor(11,0);
    lcd1.print(minutes);
    lcd1.print(":");
    for(seconds=0;seconds<=59;seconds++)
    {
    lcd1.setCursor(13,0);
    lcd1.print(seconds);
    delay(1000);
    
    }
    lcd1.setCursor(11,0);
    updated_minutes = minutes+1;
    lcd1.print( updated_minutes);
    lcd1.print(":");
    updated_seconds = seconds-59;
    lcd1.setCursor(13,0);
    lcd1.print(updated_seconds);
   digitalWrite(A3, LOW); 
   digitalWrite(A4, HIGH);
   lcd1.clear();
  }
  for(seconds=duration;seconds>=0;seconds=seconds-1)
  {
    lcd1.setCursor(0,0);
    lcd1.print("Duration:    ");

   lcd1.setCursor(11,0);
   lcd1.print(seconds);
    digitalWrite(A3, HIGH);
    digitalWrite(A4, LOW);
 
   delay(1000);
     
  }
}
else 
{
digitalWrite(A3, LOW);  
}
}  

Credits

robogamishivansh
1 project • 0 followers
Contact
sumitbranfigo
7 projects • 6 followers
Contact

Comments

Please log in or sign up to comment.