Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define LED 8
- bool SwitchF[8] = {true, true, true, false,false, true, true, true};
- int SwitchState[8] = {0, 0, 0, 0, 0, 0, 0, 0};
- bool BlinkF[8] = {false, false, false, false, false, false, true, true,};
- int BlinkState[8] = {0, 0, 0, 0, 0, 0, 0, 0};
- long BlinkTime[8];
- int LastState[8];
- int INPins[8] = {2,3,4,0,1,5,6,7};
- int OUTPins[8] = {9,10,A0,A1,A2,A3,A4,A5};
- long blikacka = 0 ;
- int blika = 0;
- long starttime = millis();
- void setup() {
- pinMode(LED, OUTPUT);
- for (int i = 0; i < 8; i++) {
- pinMode(INPins[i], INPUT);
- pinMode(OUTPins[i], OUTPUT);
- }
- }
- void loop() {
- starttime = millis();
- // put your main code here, to run repeatedly:
- for (int i = 0; i < 8; i++) {
- if (LastState[i] != digitalRead(INPins[i])) {
- LastState[i] = digitalRead(INPins[i]);
- if (SwitchF[i]) {
- if (LastState[i] == 0) {
- if (SwitchState[i] == 0) {
- digitalWrite(OUTPins[i], HIGH);
- SwitchState[i] = 1;
- BlinkTime[i] = millis();
- if (BlinkF) BlinkState[i] = 1;
- } else {
- digitalWrite(OUTPins[i], LOW);
- SwitchState[i] = 0;
- }
- }
- } else {
- digitalWrite(OUTPins[i], LastState[i]);
- }
- }
- if (SwitchF[i]) {
- if (BlinkF[i]) {
- if (SwitchState[i] == 1) {
- if (millis() - BlinkTime[i] >= 400) {
- BlinkTime[i] = millis();
- if (BlinkState[i] == 1) {
- digitalWrite(OUTPins[i], LOW);
- BlinkState[i] = 0;
- } else {
- digitalWrite(OUTPins[i], HIGH);
- BlinkState[i] = 1;
- }
- }
- }
- }
- }
- //Kontrolka behu MCU
- if (millis() - blikacka >= 400) {
- blikacka = millis();
- if (blika == 1) {
- digitalWrite(LED, LOW);
- blika = 0;
- } else {
- digitalWrite(LED, HIGH);
- blika = 1;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement