Papermind

pullup pulldown

Jan 16th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. int led1 = 13;
  2. int PBPU = 2; button that uses the INPUT_PULLUP
  3. PBPD int = 3; button that uses the INPUT_PULLDOWN
  4.  
  5. void setup () {
  6. pinMode (led1, OUTPUT);
  7. pinMode (PBPU, INPUT_PULLUP);
  8. pinMode (PBPD, INPUT); }
  9.  
  10. void loop () {
  11. int BtnPU = digitalRead (PBPU);
  12. int BtnPD = digitalRead (the PBPD);
  13. If (BtnPU == LOW) {//when the button is pressed PULLUP
  14. digitalWrite (led1, HIGH); }
  15. If (BtnPD == HIGH) {//when the PULLDOWN button pressed
  16. digitalWrite (led1, LOW);} }
Advertisement
Add Comment
Please, Sign In to add comment