// Define pin numbers const int buttonPin = 27; // Pin for the button const int ledPin = 26; // Pin for the LED // Variable to store the button state int buttonState = 0; void setup() { // Initialize the button pin as an input with internal pull-up resistor pinMode(buttonPin, INPUT_PULLUP); // Initialize the LED pin as an output pinMode(ledPin, OUTPUT); // Start with the LED and motor turned off digitalWrite(ledPin, LOW); } void loop() { // Read the state of the button buttonState = digitalRead(buttonPin); // Check if the button is pressed if (buttonState == HIGH) { // Turn on the LED digitalWrite(ledPin, HIGH); } else { // Turn off the LED digitalWrite(ledPin, LOW); } }