Skip to content

Instantly share code, notes, and snippets.

@rayanfer32
Last active January 28, 2020 08:04
Show Gist options
  • Save rayanfer32/01d1a03ff3b376e964296c1276c3865d to your computer and use it in GitHub Desktop.
Save rayanfer32/01d1a03ff3b376e964296c1276c3865d to your computer and use it in GitHub Desktop.
DESIGN AND FABRICATION OF SMART TOILET CLEANER
#include <LiquidCrystaI.h> // includes the LiquidCrystaI Library
#define rightMotorDir 2 //Sprayer Motor
#define rightMotorPwm 3
#define leftMotorDir 4 //Brush Motor
#define leftMotorPwm 5
#define button1 6 //Button 1 for case 1
#define button2 7
const int rs=8, en = 9, d4=10, d5 = 11 , d6=12,d7=13;
LiquidCrystaI Icd(rs, en, d4, d5, d6, d7);
int state1;
int state2;
int i=0;
void setup()
{
pinMode(rightMotorDir,OUTPUT); pinMode(rightMotorPwm,OUTPUT);
pinMode(leftMotorDir,OUTPUT); pinMode(leftMotorPwm,OUTPUT);
lcd.begin(16,2);
pinMode(button1,INPUT_PULLUP);
pinMode(button2,INPUT_PULLUP);
}
void loop()
{
state1 = digitalRead(button1);
state2 = digitalRead(button2);
lcd.setCursor(1,0);
lcd.print("THE SMART TOILET CLEANER");
delay(400); // 0.4 seconds
for (int positionCounter=0; positionCounter<25; positionCounter++)
{
lcd.scrollDisplayLeft(); delay(100);
}
delay(1000);
lcd.clear(); // Clears the display
if(state1 == LOW) // btn1 on
{
//Turning on the sprayer motor for 10 sec
lcd.setCursor(1, 1); lcd.print("SPRAYER 0N"); // Prints "SPRAYER ON" on the LCD
digitalWrite(rightMotorDir, HIGH); //make direction low for anticlockwise
analogWrite (rightmotorPwm,500); //speed in range of 0 to 255
delay(10000); //delay for 10 second
lcd.clear(); // Clears the display
//Waiting for 10 min
lcd.setCursor(1,1); load.print("PLEASE WAIT!!!");
digitalwrite(rightMotorDir,LOW); analogWrite(rightMotorPwm, LOW);
delay(60000*10);
lcd.clear(); // Clears the display
lcdsetCursor(0, 0); lcdprint("CLEANING IN");
lcd.setCursor(0, 1); lcd.print("PROGRESS...");
for(i=0; i<50 ; i++)
{
//Turning on the brush motor for 90 sec
digitalWrite(leftmotorDir,HIGH);
analogWrite(leftMotorpwm, 255);
delay(200);
digitalWrite(leftMotorDir, LOW);
analogWrite(leftMotorpwm, 255);
delay(240);
}
analogWrite(leftMotorpwm, LOW);
lcd.clear; // Clears the LCD screen
lcd.setCursor(1, 0);
lcd.print("YOUR TOILET IS 80% CLEANER");
delay (400);
for (int positionCounter=0; positionCounter<31; positionCounter++)
{
lcd.scrolldisplayleft();
delay(100);
}
lcd.clear();
}
if(state2==LOW) // if btn2 is on
{
// Turning on the sprayer motor for 10 sec
lcd.setcursor(1, 1);
lcd.print("SPRAYER ON");//Prints "Arduino" on the LCD
digitalwrite(rightMotorDir,HIGH); // make direction low for anticlockwise
analogWrite(rightmotorPwm,180); //range of 0 to 255 //75% speed
delay(5000); //100 per second
lcd.clear();// Clears the display
// Waiting for 10 min
lcd.setcursor(1, 1);
lcd.print("PLEASE WAIT!!");
digitalwrite(rightMotorDir,LOW);
analogWrite(rightMotorPwm,LOW);
delay(60000);
lcd.clear();// Clears the display
lcd.setcursor(0, 0);
lcd.print("CLEANING IN");
lcd.setcursor(0, 1)
lcd.print("progress");
for (i=0; i<35; i++)
{
//Turning on the brush motor for 5 sec
digitalwrite(leftMotorDir, HIGH); // clockwise
analogWrite(leftMotorPwm, 255); // speed
delay(200);
digitalwrite(leftMotorDir, LOW); // anticlock
analogWrite(leftMotorpwm, 255); // speed
delay(200);
}
lcd.clear();//clears the LCD screen
analogWrite(leftMotorPwm, LOW);
lcd.setCursor(1, 0);
lcd.print("YOUR TOILET IS NOW 80% CLEANER");
delay (400);
for (int positionCounter=0; positionCounter<31; positionCounter++)
{
lcd.scrollDisplayLeft();
delay (100);
}
lcd.clear();
} //end of case 2
}//end of while loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment