Guest User

Untitled

a guest
Nov 18th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. const int buttonPin1 = 1;
  2. const int buttonPin2 = 2;
  3. const int buttonPin3 = 3;
  4. const int buttonPin4 = 4;
  5. const int buttonPin5 = 5;
  6. const int buttonPin6 = 6;
  7.  
  8. int buttonState1 = 0;
  9. int buttonState2 = 0;
  10. int buttonState3 = 0;
  11. int buttonState4 = 0;
  12. int buttonState5 = 0;
  13. int buttonState6 = 0;
  14.  
  15. void setup() {
  16. Serial.begin(9600);
  17. pinMode(buttonPin1, INPUT_PULLUP);
  18. pinMode(buttonPin2, INPUT_PULLUP);
  19. pinMode(buttonPin3, INPUT_PULLUP);
  20. pinMode(buttonPin4, INPUT_PULLUP);
  21. pinMode(buttonPin5, INPUT_PULLUP);
  22. pinMode(buttonPin6, INPUT_PULLUP);
  23. }
  24.  
  25. void loop() {
  26. buttonState1 = digitalRead(buttonPin1);
  27. buttonState2 = digitalRead(buttonPin2);
  28. buttonState3 = digitalRead(buttonPin3);
  29. buttonState4 = digitalRead(buttonPin4);
  30. buttonState5 = digitalRead(buttonPin5);
  31. buttonState6 = digitalRead(buttonPin6);
  32.  
  33. if (buttonState1 == HIGH) {
  34. Serial.println("button1 press");
  35. }
  36. if (buttonState2 == HIGH){
  37. Serial.println("button2 press");
  38. }
  39. else if (buttonState3 == HIGH){
  40. Serial.println("button3 press");
  41. }
  42. else if (buttonState4 == HIGH){
  43. Serial.println("button4 press");
  44. }
  45. else if (buttonState5 == HIGH){
  46. Serial.println("button5 press");
  47. }
  48. else if (buttonState6 == HIGH){
  49. Serial.println("button6 press");
  50. }
  51. else{
  52.  
  53. }
  54. }
Add Comment
Please, Sign In to add comment