/* Code written by Hertz & Madden on 25/07/2021 * Foot pedal activated water tap */ const int SolenoidA = 10; // Connect the INPUTA1 of the IC to Digital Pin 10 on the Arduino const int SolenoidB = 11; // Connect the INPUTA2 of the IC to Digital Pin 11 on the Arduino const int SwitchPin = 3; // Connect the output pin of the pushbutton to Digital Pin 3 on the Arduino const int LED = 2; // Connect the positive pin of the LED to Digital Pin 2 on the Arduino int Switchstate = 0; // Set the initial switch state to LOW void setup() { pinMode(SolenoidA,OUTPUT); // Set the Digital Pin 10 as an output pinMode(SolenoidB,OUTPUT); // Set the Digital Pin 11 as an output digitalWrite(SolenoidA,HIGH); // Close the solenoid valve digitalWrite(SolenoidB,LOW); pinMode(LED,OUTPUT); // Set the Digital Pin 2 as an output digitalWrite(LED,LOW); // Turn off the LED pinMode(SwitchPin,INPUT); // Set the Digital Pin 3 as an input } void loop() { Switchstate = digitalRead(SwitchPin); // Read the output of the button and declare it as Switchstate if(Switchstate==HIGH){ // If the foot pedal is pushed digitalWrite(LED,HIGH); digitalWrite(SolenoidA,LOW); digitalWrite(SolenoidB,HIGH); delay(2000); // Turn on the LED and open the valve for 2 seconds } else if(Switchstate==LOW){ // If the foot pedal is released digitalWrite(LED,LOW); digitalWrite(SolenoidA,HIGH); digitalWrite(SolenoidB,LOW); delay(200); // Turn off the LED and close the valve } }