Detect switch on digitalread

  1. const int buttonPin = 3;
  2. int buttonState = 0;    
  3.  
  4. void setup() {
  5.   Serial.begin(9600);  
  6.   pinMode(buttonPin, INPUT);    
  7. }
  8.  
  9. void loop(){
  10.   buttonState = digitalRead(buttonPin);
  11.   Serial.println(buttonState);
  12. }

2 thoughts on “Detect switch on digitalread

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>