RBE1001Lib
Button.ino
Go to the documentation of this file.
1 const int buttonPin = 0; // the number of the pushbutton pin
2 const int ledPin = 33; // the number of the LED pin
3 
4 void setup()
5 {
6  pinMode(ledPin, OUTPUT); // initialize the LED pin as an output
7  pinMode(buttonPin, INPUT_PULLUP); // initialize the pushbutton pin as an input (w/pullup)
8 }
9 
10 void loop()
11 {
12  // read the state of the pushbutton value:
13  int buttonState = digitalRead(buttonPin);
14 
15  // check if the pushbutton is pressed.
16  // if it is, the buttonState is LOW (inverted logic!):
17  if (buttonState == LOW)
18  {
19  // turn LED on:
20  digitalWrite(ledPin, HIGH);
21  }
22  else
23  {
24  // turn LED off:
25  digitalWrite(ledPin, LOW);
26  }
27 }
void loop()
Definition: Button.ino:10
const int buttonPin
Definition: Button.ino:1
void setup()
Definition: Button.ino:4
const int ledPin
Definition: Button.ino:2