josephcassio
Published

Shower Timer

This is a great tool to reduce water waste. The second someone uses the shower it will start a timer and in the end, an alarm will sound.

IntermediateWork in progress1,368
Shower Timer

Things used in this project

Story

Read more

Schematics

Scamatics

The two wires on opposite sides of the switch are the two connecting plates.

Code

Code

C/C++
This starts a timer for 5 minutes when the two plates sense water.
const int buttonPin = 2;
const int alarm = 4;
int buttonState = 0;



void setup() {
  
  pinMode(buttonPin, INPUT);
  pinMode(alarm, OUTPUT);
  Serial.begin(9600);
  Serial.print("Hi");
}

void loop() {


  buttonState = digitalRead(buttonPin);

  if(buttonState == HIGH){
Serial.print("alarm");
tone(alarm, 200);
delay(2000);
noTone(alarm);

  delay(30000);
  delay(30000);
  delay(30000);
  delay(30000);
  delay(30000);
  delay(30000);
  delay(30000);
  delay(30000);
  delay(30000);
  delay(30000);


for (int i = 0; i <= 3; i++) {
  tone(alarm, 100);
  delay(1500);
  tone(alarm, 200);
  delay(1500);
}

noTone(alarm);

  
    
   }
   else{
    
    }

}

Credits

josephcassio
0 projects • 0 followers

Comments