Hi,
I am new to the world of arduino. For my first project I was working on a automatic pump controller for an overhead tank.
My circuit is similar to this other than I have used a TIP122 to control the relay. There is no probe for sump and no buzzer
The core that I have written is :
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Initialize LCD display pins
int L1=A0;
int L2=A1;
int L3=A2;
int L4=A3;
int motor=13;
int c=100;
int q;
int h;
int t;
int f;
int ms=0;
void setup()
{
delay(500); // delay 0.5 sec for LCD to initialize
lcd.begin(16,2);
lcd.print("Initializing...");
lcd.setCursor(0,1);
lcd.print(" Please Wait!!!");
pinMode(L1, INPUT);
pinMode(L2, INPUT);
pinMode(L3, INPUT);
pinMode(L4, INPUT);
pinMode(motor, OUTPUT);
delay(5000); // 5 sec delay incase of power faliure
lcd.clear();
ms=0;
}
void loop()
{
q=analogRead(L1);
h=analogRead(L2);
t=analogRead(L3);
f=analogRead(L4);
if(ms==1)
{
digitalWrite(motor, HIGH);
lcd.setCursor(0,1);
lcd.print("PUMP: ON ");
}
else
{
if(ms==0)
{
digitalWrite(motor, LOW);
lcd.setCursor(0,1);
lcd.print("PUMP: OFF");
}
}
if(q>c && h>c && t>c && f>c)
{
lcd.setCursor(0,0);
lcd.print("Water Lvl E F");
lcd.setCursor(11,0);
lcd.print(char(255));
lcd.print(char(255));
lcd.print(char(255));
lcd.print(char(255));
ms=0;
}
else
{
if(q>c && h>c && t>c && f<c)
{
lcd.setCursor(0,0);
lcd.print("Water Lvl E F");
lcd.setCursor(11,0);
lcd.print(char(255));
lcd.print(char(255));
lcd.print(char(255));
lcd.print(" ");
}
else
{
if(q>c && h>c && t<c && f<c)
{
lcd.setCursor(0,0);
lcd.print("Water Lvl E F");
lcd.setCursor(11,0);
lcd.print(char(255));
lcd.print(char(255));
lcd.print(" ");
lcd.print(" ");
}
else
{
if(q>c && h<c && t<c && f<c)
{
lcd.setCursor(0,0);
lcd.print("Water Lvl E F");
lcd.setCursor(11,0);
lcd.print(char(255));
lcd.print(" ");
lcd.print(" ");
lcd.print(" ");
}
else
{
if(q<c && h<c && t<c && f<c)
{
lcd.setCursor(0,0);
lcd.print("Water Lvl E F");
lcd.setCursor(11,0);
lcd.print(" ");
lcd.print(" ");
lcd.print(" ");
lcd.print(" ");
ms=1;
}
// else
// {
// lcd.clear();
// lcd.print(" ***ERROR*** PLEASE RESET");
// while(1);
// }
}
}
}
}
delay(1000);
}
Now everything was working fine until the transistor which i was using earlier i.e. BC337 shorted out. So I decided to swap it out with TIP122. It was working fine until it started causing problems. It was switching on even with base disconnected from pin 13. Found out the flux from soldering was the main culprit.
After that incident the arduino keeps on freezing every 15 to 20 mins and then resets itself. Sometimes it even freezes up immediately after resetting.
Tried uploading the code again but it keeps doing the same thing.
Can anybody help me out with this???