PowerTGS440

Untitled

Feb 5th, 2021
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #include <Button.h>
  2. #define bINTERVAL 4000
  3.  
  4. #define button_pin1 6
  5. #define button_pin2 7
  6. #define button_pin3 8
  7. #define button_pin4 9
  8.  
  9. #define dioda1 1
  10. #define dioda2 2
  11. #define dioda3 3
  12. #define dioda4 4
  13.  
  14. Button przycisk1 = Button(button_pin1, bINTERVAL);
  15. Button przycisk2 = Button(button_pin1, bINTERVAL);
  16. Button przycisk3 = Button(button_pin1, bINTERVAL);
  17. Button przycisk4 = Button(button_pin1, bINTERVAL);
  18.  
  19. int ledy[4] = { 0, 0, 0, 0 };
  20.  
  21. voide setup()
  22. {
  23. pinMode(dioda1, OUTPUT);
  24. pinMode(dioda2, OUTPUT);
  25. pinMode(dioda3, OUTPUT);
  26. pinMode(dioda4, OUTPUT);
  27. }
  28.  
  29.  
  30. void loop()
  31. {
  32. button1.listen();
  33. button2.listen();
  34. button3.listen();
  35. button4.listen();
  36.  
  37. if(button1.onPress())
  38. {
  39. if(ledy[0] == 0) ledy[0] = 1;
  40. else
  41. if(ledy[0] == 1) ledy[0] = 0;
  42. }
  43.  
  44. if(button2.onPress())
  45. {
  46. if(ledy[1] == 0) ledy[0] = 1;
  47. else
  48. if(ledy[1] == 1) ledy[0] = 0;
  49. }
  50.  
  51. if(button2.onPress())
  52. {
  53. if(ledy[2] == 0) ledy[0] = 1;
  54. else
  55. if(ledy[2] == 1) ledy[0] = 0;
  56. }
  57.  
  58. if(button3.onPress())
  59. {
  60. if(ledy[3] == 0) ledy[0] = 1;
  61. else
  62. if(ledy[3] == 1) ledy[0] = 0;
  63. }
  64.  
  65. akcja_z_ledami();
  66.  
  67. }
  68.  
  69. // ----------------------------------------
  70.  
  71.  
  72. void akcja_z_ledami()
  73. {
  74.  
  75. if (ledy[0] == 0) digitalWrite(dioda1, HIGH);
  76. else digitalWrite(dioda1, LOW);
  77.  
  78. if (ledy[1] == 0) digitalWrite(dioda2, HIGH);
  79. else digitalWrite(dioda2, LOW);
  80.  
  81. if (ledy[2] == 0) digitalWrite(dioda3, HIGH);
  82. else digitalWrite(dioda3, LOW);
  83.  
  84. if (ledy[3] == 0) digitalWrite(dioda4, HIGH);
  85. else digitalWrite(dioda4, LOW);
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment