Created
December 12, 2017 10:27
-
-
Save Caellian/80c6538a3c670ea9a0a7a87ad26858a2 to your computer and use it in GitHub Desktop.
LV7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int led[] = {6, 7, 8, 9, 10, 11, 12, 13}; | |
| int leds() { | |
| return sizeof(led) / sizeof(int); | |
| } | |
| void setup() { | |
| for (int i = 0; i < leds(); i++) { | |
| pinMode(led[i], OUTPUT); | |
| } | |
| } | |
| void loop() { | |
| for (int i = 0; i < leds(); i+=2) { | |
| digitalWrite(led[i], HIGH); | |
| delay(75); | |
| digitalWrite(led[i + 2], HIGH); | |
| digitalWrite(led[i], LOW); | |
| } | |
| for (int i = leds(); i >= 0; i-=2) { | |
| digitalWrite(led[i], HIGH); | |
| delay(75); | |
| digitalWrite(led[i - 2], HIGH); | |
| digitalWrite(led[i], LOW); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int PIN_SW1 = 11; | |
| int PIN_SW2 = 12; | |
| int PIN_led = 8; | |
| int verifyA = 0; | |
| int verifyB = 0; | |
| int slowdownEffect = 1000; | |
| int slowbuff = slowdownEffect; | |
| void setup() { | |
| pinMode(PIN_SW1, INPUT_PULLUP); | |
| pinMode(PIN_SW2, INPUT_PULLUP); | |
| pinMode(PIN_led, OUTPUT); | |
| Serial.begin(9600); | |
| } | |
| void loop() { | |
| verifyA = digitalRead(PIN_SW1); | |
| verifyB = digitalRead(PIN_SW2); | |
| Serial.print("Activation: A - "); | |
| Serial.print(verifyA); | |
| Serial.print("\n"); | |
| Serial.print("Activation: B - "); | |
| Serial.print(verifyB); | |
| Serial.print("\n"); | |
| if (verifyA == 0 && verifyB == 0) { | |
| digitalWrite(PIN_led, HIGH); | |
| Serial.print("Authorisation granted!\n"); | |
| } else { | |
| digitalWrite(PIN_led, LOW); | |
| Serial.print("Request terminated!\n"); | |
| } | |
| Serial.print("\n"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment