Question: jan 2 4 a . ino int buttonPin = 2 ; int ledPin = 1 3 ; / / variables will change: / / the

jan24a.ino
int buttonPin =2;
int ledPin =13;
// variables will change:
// the number of the pushbutton pin
}
// the number of the LED pin
// variable for reading the pushbutton status
int buttonstate;
int ledState = LOW; // variable to store the LED state: HIGH = on, LOW = off
void setup(){ pinMode(2, INPUT); pinMode(13, OUTPUT);
}
void
// read the state of the pushbutton value: buttonState = digitalRead( buttonPin );
// If the button has been pressed, and the LED is OFF
if ( buttonstate == ON && ledState == LOW) turn LED on:
digitalWrite(13,HIGH) ;
ledState = ON;
}
//If the button has been pressed, a nd the LED is ON
else if (buttonstate == OFF & ledState == HIGH) turn LED off:
digitalWrite(13, LOW) ;
ledState = OFF ;
}
delay(100); // delay in order to give some time to read the button press
//you can change this value and observe the difference
}
Output
/private/var/folders/sf/rlcqfn_552d3l9kmwln6l6qh0000gn/T/.arduinoIDE-unsaved2024024-35185-abiv4q.umon/sketch_jan24a/sketch_jan24a. ino:5:1: error: expected declaration
 jan24a.ino int buttonPin =2; int ledPin =13; // variables will change:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!