EasyManua.ls Logo

Eckstein komponente KS0530 - Page 103

Default Icon
160 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
103
button
http://www.keyestudio.com
*/
#define LED 3 //define the LED pin as D3
#define button 2 //define the pin of push button module as D2
volatile int buttonState; //the state of the level output by the push
void setup()
{
Serial.begin(9600); //set baud rate to 9600
pinMode(button, INPUT); // initialize digital pin button as an input.
pinMode(LED, OUTPUT); // initialize digital pin LED as an output.
}
void loop ()
{
buttonState = digitalRead(button); //read the state of the push
button module
if (buttonState == 0) //if the button is pressed
{
digitalWrite(LED, HIGH); //the LED lights up
}