Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Button.h>
- #define bINTERVAL 4000
- #define button_pin1 6
- #define button_pin2 7
- #define button_pin3 8
- #define button_pin4 9
- #define dioda1 1
- #define dioda2 2
- #define dioda3 3
- #define dioda4 4
- Button przycisk1 = Button(button_pin1, bINTERVAL);
- Button przycisk2 = Button(button_pin1, bINTERVAL);
- Button przycisk3 = Button(button_pin1, bINTERVAL);
- Button przycisk4 = Button(button_pin1, bINTERVAL);
- int ledy[4] = { 0, 0, 0, 0 };
- voide setup()
- {
- pinMode(dioda1, OUTPUT);
- pinMode(dioda2, OUTPUT);
- pinMode(dioda3, OUTPUT);
- pinMode(dioda4, OUTPUT);
- }
- void loop()
- {
- button1.listen();
- button2.listen();
- button3.listen();
- button4.listen();
- if(button1.onPress())
- {
- if(ledy[0] == 0) ledy[0] = 1;
- else
- if(ledy[0] == 1) ledy[0] = 0;
- }
- if(button2.onPress())
- {
- if(ledy[1] == 0) ledy[0] = 1;
- else
- if(ledy[1] == 1) ledy[0] = 0;
- }
- if(button2.onPress())
- {
- if(ledy[2] == 0) ledy[0] = 1;
- else
- if(ledy[2] == 1) ledy[0] = 0;
- }
- if(button3.onPress())
- {
- if(ledy[3] == 0) ledy[0] = 1;
- else
- if(ledy[3] == 1) ledy[0] = 0;
- }
- akcja_z_ledami();
- }
- // ----------------------------------------
- void akcja_z_ledami()
- {
- if (ledy[0] == 0) digitalWrite(dioda1, HIGH);
- else digitalWrite(dioda1, LOW);
- if (ledy[1] == 0) digitalWrite(dioda2, HIGH);
- else digitalWrite(dioda2, LOW);
- if (ledy[2] == 0) digitalWrite(dioda3, HIGH);
- else digitalWrite(dioda3, LOW);
- if (ledy[3] == 0) digitalWrite(dioda4, HIGH);
- else digitalWrite(dioda4, LOW);
- }
Advertisement
Add Comment
Please, Sign In to add comment