#include SoftwareSerial mySerial(5, 1); const int ledPin = 10; const int buttonPin = 9; bool state; bool previousState; void setup() { Serial.begin(9600); pinMode (ledPin, OUTPUT); pinMode (buttonPin, INPUT); state = false; previousState = state; } void loop() { if (digitalRead(buttonPin) && !previousState) { state = !state; previousState = true; digitalWrite(ledPin, state); if (state) { Serial.println("LED OFF"); } else { Serial.println("LED ON"); } } if (!digitalRead(buttonPin)) { previousState = false; } }