Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based Timer-Controlled Relay with Rotary Encoder and LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Timer-Controlled Relay with Rotary Encoder and LCD Display

Circuit Documentation

Summary

This circuit is designed around an Arduino UNO microcontroller and includes a variety of components such as a rotary encoder, a 16x2 LCD display, a 1-channel relay, a trimmer potentiometer, a current sensor, a socket, a flush switch, and an AC supply. The primary function of this circuit is to control and display a timer, which can be set using the rotary encoder. The timer's countdown is displayed on the LCD, and upon completion, it activates a relay which could control an external device. The current sensor is used to monitor the current flow, and the system's settings can be saved and retrieved from EEPROM.

Component List

Wiring Details

Arduino UNO

Rotary Encoder

16X2 LCD

1-Channel Relay (5V 10A)

Trimmer Potentiometer

Socket

Flush Switch

AC Supply

Current Sensor 5A

Documented Code

#include<LiquidCrystal.h>
#include<EEPROM.h>
LiquidCrystal lcd (8,7,6,5,4,3); 
#define outputA 10 //clk pin of rotary encoder 
#define outputB 11 //dt pin of rotary encoder 
#define button 2   //sw pin of rotary encoder 
#define led 13     //status led
#define relay 12   //in1 of relay

int count = 1; 
int current_state;
int previous_state;  
int hh =0;
int mm=0;
int ss=0;
int h=0;
int m=0;
int s=0;
int ledToggle;
int previousState = HIGH;
unsigned int previousPress;
volatile int buttonFlag;
int buttonDebounce = 20;

void setup() 
{ 
  lcd.begin(16,2);
  pinMode (outputA,INPUT);
  pinMode (outputB,INPUT);
  pinMode (button,INPUT_PULLUP);
  pinMode (led, OUTPUT);
  pinMode (relay, OUTPUT);
  digitalWrite(relay, HIGH);
  attachInterrupt(digitalPinToInterrupt(2), button_ISR, CHANGE);
  Serial.begin (9600);
  previous_state = digitalRead(outputA);   
}

void loop() 
{ 
  encoder();
  // The rest of the loop code handles the user interface and timer logic
}

void encoder (void)
{
  // This function reads the rotary encoder position and updates the count
}

void button_ISR()
{
  // This interrupt service routine handles the button press event
}

void timer (void)
{
  // This function handles the countdown timer logic and display
}

Note: The code provided above is a partial representation of the full code. The full code includes functions for handling the rotary encoder input, button press interrupts, and the countdown timer logic. The code also includes EEPROM read/write operations to save and retrieve the timer settings.