const int BUTTON_PIN = 27; // the number of the pushbutton pin const int VACUUM_PIN = 26; // the number of the pump pin (28 for pump, 26 for LED) int buttonState = 0; // variable for reading the pushbutton status bool lastButtonState = LOW; bool pumpState = LOW; void setup() { pinMode(VACUUM_PIN, OUTPUT); // pump is defined as output pinMode(BUTTON_PIN, INPUT); // pushbutton is defined as input Serial.begin(9600); } void loop() { // read button status int reading = digitalRead(BUTTON_PIN); // check if button status changed if (reading != lastButtonState) { if (reading == HIGH) { //change pump state pumpState = !pumpState; digitalWrite(VACUUM_PIN, pumpState); Serial.print("pump state is "); Serial.println(pumpState ? "open" : "off"); } } lastButtonState = reading; }