Old flatbed scanner (Pick one with enough space for LCD, PCB boards and Potentiometer BOM below.
And my rats nest for testing. The UV box that I’m using right now has this circuit and is point to point wired with soldered jumpers, everything held in place by some fancy hot glue haha….
Display and arduino +relay is also powered with the same 12V power supply that are used for the UV led strips by the use of a 12v-5v DC-DC buck converter.
//Most of the code “by
https://robojax.com/” A few modifications to suite my needs for a PCB UV exposure board.
//I also finally managed to get the i2c display code to become flicker free.. eureka! ;)
// start of settings for HD44780 with I2C
#include <Arduino.h>
#include <LiquidCrystal_I2C.h>
#include <IoAbstractionWire.h>
#include<Wire.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define relayPin 8 // the pin relay is connected
#define potPin A0 // the pin potentiometer is connected
#define resetPin 3 // the pin where rest switch is connected
#define startPin 2 // the pin where start switch is connected
#define relayType ‘L’ // Relay trigger type. L for low and H for high
const int maxTime = 200;// maximum timer time in seconds 2 minutes is more than enough for my PCB UV box
const int minTime = 2; // miniimum timer time in seconds
// do not change anything bellow here
long duration;// holds the duration of timer
int potValue;// holds the variable resistor (potentiometer) value
long rememTime;// holds current run time
int relayState =0;// holds relay state
void setup() {
lcd.begin(16, 2);
lcd.backlight();
lcdDisplay(0, “Set-time:”, ” ” , “.S” );
lcdDisplay(1, “Awating start! “, 0, ” “);
Wire.begin();
pinMode(relayPin, OUTPUT);
pinMode(resetPin, INPUT_PULLUP);
pinMode(startPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(resetPin), reset, LOW);
Serial.begin(115200);// initialize serial monitor with 9600 or your choice of baud rate.
if(relayType == ‘H’) // H or L depending on activted LOW or activeted HIGH by pin 8.
{
digitalWrite(relayPin, HIGH);// turn the relay OFF and keep it OFF.
Serial.println(“Countdown relay”);
Serial.println(“Type:LOW Trigger”);
}else{
digitalWrite(relayPin, LOW);// turn the relay OFF and keep it OFF.
Serial.println(“Countdown relay”);
Serial.println(“Type:HIGH Trigger”);
}
delay(0);
}
void loop() {
potValue = analogRead(potPin)/10;// reads the value of the potentiometer I use 10K multi turn pot (value between 0 and 1023).
int durationCalc = map(potValue, 0, 102, minTime, maxTime);// convert A0 value to time set minTime and maxTime.
if(digitalRead(startPin) ==LOW)
{
duration = durationCalc;
rememTime = millis()/1000;
relayState = 1;
controlRelay();// turns the relay ON
}
if( ( millis()/1000- rememTime) > duration )
{
relayState = 0;// change relay state to OFF
controlRelay();// control relay with new relay state
}
Serial.print(“Time set: “);
Serial.print(duration);
Serial.print (” S “);
if(relayState ==1){
lcd.noBlink();
lcdDisplay(0, “Run-time: “, duration, “.S”);
lcdDisplay(1, “Exposing: “, getRtime(), “.S “);
Serial.print(” remain: “);
Serial.print(getRtime());//
Serial.print(” .S”);
}else{
lcd.noBlink();
lcdDisplay(0, “Set-time: “, durationCalc, “.S”);
lcdDisplay(1, “Awating start! “, 0, “”);
}
Serial.println();
delay(50); // wait for 200 milliseconds
}// loop end
void controlRelay()
{
if(relayType == ‘L’)
{
if(relayState == 1)
{
digitalWrite(relayPin, LOW);// turns Low-Trigger relay ON
Serial.print(“LT-Relay ON for “);
Serial.print(duration);// display in seconds
Serial.println(” Seconds”);
}else{
digitalWrite(relayPin, HIGH); // turns Low-Trigger relay OFF
Serial.println(“====Relay is OFF”);
}
}else{
if(relayState == 1)
{
digitalWrite(relayPin, HIGH);// turns High-Trigger relay ON
Serial.print(“HT-Relay ON for “);
Serial.print(duration);// display in seconds
Serial.println(” Seconds”);
}else{
digitalWrite(relayPin, LOW); // turns High-Trigger relay OFF
Serial.println(“==Relay OFF”);
}
}
}//controlRelay end
void reset()
{
duration =0;
if(relayType == ‘L’)
{
digitalWrite(relayPin, HIGH);// turn OFF High trigger relay
}else{
digitalWrite(relayPin, LOW);// turn OFF Low trigger relay
}
Serial.println(“Relay OFF”);
}//reset()
int getRtime()
{
return duration – (millis()/1000- rememTime);
}
void lcdDisplay(int rowNum, String titleText, int valueText, String value2Text)
{
clearRow(rowNum);
String myStr;
myStr = String(valueText);
int titleTextLength = titleText.length();
lcd.setCursor (0,rowNum); //
lcd.print(titleText);
lcd.setCursor (titleTextLength,rowNum); //
lcd.print(myStr);
lcd.setCursor (myStr.length()+titleTextLength,rowNum); //
lcd.print(value2Text);
}
void clearRow(int r)
{
//
for(int i=0; i<16; i++)
{
lcd.setCursor (i,r); //
if(relayPin, LOW) lcd.print(” “);
}
}//clearRow end
If you don’t have a multi turn potentiometer on hand but still like fine controll of time settings, you can use two potentiometers in series like in the original set up se more here: robojax.com relay_timer_1.1