Advertisement
zhexo

MKR_button

Feb 6th, 2023
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const int buttonPin = 7;
  2. int buttonState = 0;
  3.  
  4. void setup() {
  5.   pinMode(LED_BUILTIN, OUTPUT);
  6.   pinMode(buttonPin, INPUT);
  7. }
  8. void loop() {
  9.   buttonState = digitalRead(buttonPin);
  10.   if (buttonState == HIGH) {
  11.     digitalWrite(LED_BUILTIN, HIGH);
  12.   } else {
  13.     digitalWrite(LED_BUILTIN, LOW);
  14.   }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement