![]() LcdDisplay(1, "Remaining: ", getRtime(), "S") LcdDisplay(0, "Time Set: ", duration, "S") RelayState = 0 // change relay state to OFFĬontrolRelay() // control relay with new relay state If( ( millis()/1000- rememTime) > duration ) Int durationCalc = map(potValue, 0, 102, minTime, maxTime) // convert A0 value to time set at minTime and maxTimeĬontrolRelay() // send command to turn the relay ON PotValue = analogRead(potPin)/10 // reads the value of the potentiometer (value between ) Relay Timer V 1.1 with LCD1602 I2C display Lcd.clear() // clearn previous values from screen Serial.begin(9600) // initialize serial monitor with 9600 baudĭigitalWrite(relayPin, HIGH) // turn the relay OFF and keep it OFFĭigitalWrite(relayPin, LOW) // turn the relay OFF and keep it OFFĭelay(3000) // change this line if you want not to wait ![]() PinMode(startPin, INPUT_PULLUP) // define input pin with pullup (watch video)ĪttachInterrupt(digitalPinToInterrupt(resetPin), reset, LOW) // Interrupt Service Routines. PinMode(resetPin, INPUT_PULLUP) // define input pin with pullup (watch video) PinMode(relayPin, OUTPUT) // define relayPin as output Lcd.backlight() // turn the backlight ON for the LCD Int potValue // holds the variable resistor (potentiometer) value Long duration // holds the duration of timer L for low and H for highĬonst int maxTime = 200 // maximum timer time in secondsĬonst int minTime = 2 // miniimum timer time in seconds #define relayType 'L' // Relay trigger type. ![]() #define startPin 2 // the pin where start switch is connected #define resetPin 3 // the pin where rest switch is connected ![]() #define potPin A0 // the pin potentiometer is connected #define relayPin 8 // the pin relay is connected Set the LCD address to 0x27 for a 16 chars and 2 line display start of settings for LCD1602 with I2C You should have received a copy of the GNU General Public License GNU General Public License for more details. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program is distributed in the hope that it will be useful,īut WITHOUT ANY WARRANTY without even the implied warranty of The Free Software Foundation, either version 3 of the License, or It under the terms of the GNU General Public License as published by This program is free software: you can redistribute it and/or modify Free to be used as long as you keep this note intact.* * This code is "AS IS" without warranty or liability. When SW1 is pressed during the run time, the timer is resetted and it will start over again When the timer is runing, if potentiometer is rotated, it will not affect the remaining time The timer can be cancelled any time pressing this switch By pushing this button the relay will turn ON and the timer is shown on LCD * -Set time by rotating potentiometer (variable resistor) * Written by Ahmad Shamshiri for on Sunday Oct 18, 2018 * Watch video instruction for this code: * this Arduino sketch makes it possible to control a relay with the set time * Version 1.1 Display is added to show the set time * Arduino code for Relay timer with potentiometer and LCD1602 with I2C Get Early Access to my videos via Patreon.Robojax Crash Course on Arduino: Learn Arduino in 30 Minutes (code and video).INPUT_PULLUP and why use Resistor (video).Code and Video Introduction to 5V 1 channel Relay (must watch).Code and Video Explaining LCD1602 with I2C (must watch).2 Wiring of Fine and coarse control for two potentiometers Resources for this sketch Specially time above 100 seconds, use two potentiometers with values 1:10 (one is 10 times larger than the other.) For example for coarse control use 100kΩ variable resistor and for fine control use 10kΩ and connect them as shown in Fig. 1 Schematic diagram for Robojax Relay Timer V 1.1 with LCD1602-I2C When SW1 is pressed during the run time, the timer is resetted and it will start over againįig.When the timer is ruining, if potentiometer is rotated, it will not affect the remaining time.Set time by rotating potentiometer (variable resistor).You can set from 0 to any number of seconds. This code is to use Arduino as timer to control relay with potentiometer and LCD1602-I2C. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |