Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions