Advertisement
PedroArthurr

Interruptor - Arduino

Feb 26th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. const int switchPin = 2;
  2. int valSwitch = 0;
  3. void setup() {
  4.   Serial.begin(9600);
  5.   pinMode(switchPin, INPUT);
  6. }
  7. void loop() {
  8.     valSwitch = digitalRead(switchPin);
  9.     if(valSwitch == HIGH){
  10.       Serial.println("0");
  11.       delay(30);
  12.     }
  13.     if(valSwitch == LOW){
  14.       Serial.println("1");
  15.       delay(30);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement