Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool SwitchF[8] = {true, true, true, true, true, true, false, false};
- int SwitchState[8] = {0, 0, 0, 0, 0, 0, 0, 0};
- bool BlinkF[8] = {false, false, false, false, true, true, false, false,};
- int BlinkState[8] = {0, 0, 0, 0, 0, 0, 0, 0};
- long BlinkTime[8];
- int LastState[8];
- int INPins[8] = {PD2,PD3,PD4,PB6,PB7,PD5,PD6,PD7};
- int OUTPins[8] ={PB1,PB2,PC0,PC1,PC2,PC3,PC4,PC5};
- long starttime = millis();
- void setup() {
- 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;
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement