Advertisement
rinaldohack

Untitled

Mar 27th, 2019
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int ledPin = 13;  // LED connected to digital pin 13
  2. int inPin = 2;    // pushbutton connected to digital pin 7
  3. int val = 0;      // variable to store the read value
  4.  
  5. void setup() {
  6.   Serial.begin(115200);
  7.   pinMode(ledPin, OUTPUT);  // sets the digital pin 13 as output
  8.   pinMode(inPin, INPUT);    // sets the digital pin 7 as input
  9. }
  10.  
  11. void loop() {
  12.   val = digitalRead(inPin);   // read the input pin
  13.   digitalWrite(ledPin, val);  // sets the LED to the button's value
  14.   Serial.println(val);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement