Sorry for the messy schematic, but it is the first time i use Frizz.
The whole system is powered through an adapter from 220V that will give me 5V.
The relay interrupts the live wire from the pump.
The software it's simple:
const int buttonPin1 = 2;// float
const int buttonPin2 = 3; // button reset
const int ledPin = 7;// Relay
const int pinPower = 9; //Power led
int buttonState1 = 0;
int buttonState2 = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode (pinPower, OUTPUT);
digitalWrite (pinPower, HIGH);
}
void loop(){
// read the state of the pushbutton value:
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState1 == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
//tone(8, 1200, 1000);
// delay (1000);
tone(8,800);
}
if (buttonState2 == HIGH) {
digitalWrite(ledPin, LOW);
noTone(8);
}
}
