This circuit works on the principle that water conducts electricity. Two wires connected to VCC and two other wires are dipped in tank at different levels namely top & bottom and their output are taken on pins P2.6, P2.7 via transistor BC547. Port P1 is connected to data pins of LCD and P3.2, P3.3, P3.4 are respectively connected to RS, RW, and EN pins of LCD.
Initially when the tank is empty,motor will be on automatically & LCD will show the message Motor on. As the tank starts filling up wire at different levels get some positive voltage, due to conducting nature of water. This voltage is then fed to their corresponding pins on controller. When tank gets full,motor will be on automatically & LCD shows the message Motor Off.
void delay(unsigned char a)
unsigned char i,j;