I recently started a project for a UV Box that will use an Arduino Un0 R3 as a timer that will send a voltage to the base of a transistor thus powering up the LED Arrays. I had the project working a few days ago - then I soldered it up and it didn't work - so I took it all apart and replaced all components - even the Arduino and the problem persists.
Here is the Code:
// include the LCD library code:
#include <LiquidCrystal.h>
int startPin = 9; //start button pin
int upPin = 6; //up button pin
int downPin = 8; //down button pin
int transistorPin = 7; //transistor base pin
int buzzerPin = 13; //piezo buzzer pin
int upRead1 = 0; //variable to read up button
int upRead2 = 0; //debounce variable for up button
int downRead1 = 0; //variable to read down button
int downRead2 = 0; //debounce variable for down button
int startRead1 = 0; //variable to read start button
int startRead2 = 0; //debounce variable for start button
int timerCount = 0; //variable for timer setting
int minutesCount = 0; //minutes value
int secondsCount = 0; //seconds value
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.print("Franklin's UVBox");
delay(2000);
lcd.clear();
lcd.print("Exposure Time?");
delay(1500);
pinMode(transistorPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(startPin, INPUT);
pinMode(upPin, INPUT);
pinMode(downPin, INPUT);
}
void lcdWrite()
{
lcd.setCursor(0, 0); //set cursor to top left
lcd.print(minutesCount); //print minutes value
lcd.setCursor(3, 0); //set cursor on other side of minutes value
lcd.print("min"); //print min string
lcd.setCursor(7, 0); //set cursor further right
lcd.print(secondsCount); //print seconds value
lcd.setCursor(10,0); //set cursor further right
lcd.print("sec"); //print sec string
}
void loop() {
//read all three buttons
upRead1 = digitalRead(upPin);
downRead1 = digitalRead(downPin);
startRead1 = digitalRead(startPin);
//debounce read for all three buttons
delay(10);
upRead2 = digitalRead(upPin);
downRead2 = digitalRead(downPin);
startRead2 = digitalRead(startPin);
//slow down button value change speed
delay(100);
//if up button pressed increment timer count and print to lcd
if(upRead1==upRead2 && upRead1==HIGH)
{
lcd.clear(); //clear screen
secondsCount = secondsCount+5; //increment in sec intervals
if(secondsCount==60) //increment minute & rest sec for every 60 sec
{
minutesCount++;
secondsCount=0;
}
lcdWrite(); //print values
}
//if down button pressed decrement timer count and print to lcd
if(downRead1==downRead2 && downRead1==HIGH)
{
lcd.clear(); //clear lcd
secondsCount = secondsCount-5; //decrement minute & reset sec for every 60 sec
if(minutesCount>0) //if more than a minute left
{
if(secondsCount==-5) // reset sec value of -5 to 55 & decrement minute
{
secondsCount=55;
minutesCount--;
}
else
{
if(secondsCount<0) //if countdown finished, reset values to zero
{
secondsCount = 0;
minutesCount = 0;
}
}
}
lcdWrite();
if(secondsCount<0)
{
secondsCount=0;
lcd.clear();
lcd.print("0");
}
}
//if start button pressed activate transistor base and
//print timer count down to lcd
//activate buzzer to signal end of count
if(startRead1==startRead2 && startRead1==HIGH)
{
timerCount = (minutesCount*60) + secondsCount;
int timerCount2 = timerCount;
Serial.println(timerCount);
for(int i=timerCount;i>0;i--)
{
lcd.clear();
if(timerCount2>60)
{
minutesCount = timerCount2/60;
secondsCount = timerCount2%60;
}
else if(secondsCount==60)
{
secondsCount=59;
}
else
{
minutesCount = 0;
secondsCount = timerCount2;
}
lcdWrite();
//send transistor base pin high
digitalWrite(transistorPin, HIGH);
delay(1000);
timerCount2--;
}
lcd.clear();
lcd.print("I am Done");
//turn transistor off
digitalWrite(transistorPin, LOW);
//turn on piezo buzzer
analogWrite(buzzerPin, 255);
delay(1000);
//turn off piezo buzzer
analogWrite(buzzerPin, 0);
delay(2000);
lcd.clear();
delay(1000);
lcd.print("Exposure Time?");
delay(1000);
//reset timer values
timerCount = 0;
minutesCount = 0;
secondsCount = 0;
}
}
Al connections are correct - the Arduino and Buzzer receive power from a 9v battery and the rest of the components(buttons, and LCD) receive power from a 5v supply - the buttons have a 10k ohm pull up resistor
The project is supposed to work like this: Arduino UV LED PCB Exposure Box - YouTube
I modified a few things to fit my needs but it is mostly the same as the original creators project
I am using this LCD: http://www.ebay.com/itm/181295337227?_trksid=p2059210.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
I would have attached images but every time I try it crashes - they are compressed and are well within the size limits
Half the time the screen is blank - backlight and logic are recieving power and the contrast pot works just fine - the other half of the time the "Franklin's UVBox" and "Exposure Time?" come up but the minute and second values do not - when I press any button random numbers, symbols and percent signs come up on the screen until I reset it - and it does it all over again.
Once again I had it working like a charm - nothing has changed from then until now which is why i'm so stumped - if anybody has any ideas please help - THANKS!