Created
October 26, 2019 04:45
-
-
Save futureshocked/a8fb3124ddf95f8143ca9895999715e8 to your computer and use it in GitHub Desktop.
Control an LED using an array.
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
| /* | |
| * Control an LED using an array. | |
| * | |
| * Create a pattern with LED on and off information in one array, | |
| * and on/off durations in a second array. | |
| * | |
| * | |
| */ | |
| const int ledPin = 7; | |
| const int totalStates = 9; | |
| int ledState[totalStates] = {1, 0, 1, 0, 1, 0, 0, 1, 0}; | |
| int ledDuration[totalStates] = {200,400,500,100,200,50, 50, 500, 500 }; | |
| void setup() { | |
| pinMode(ledPin, OUTPUT); | |
| } | |
| void loop() { | |
| for (int i = 0; i < totalStates; i++) | |
| { | |
| digitalWrite(ledPin,ledState[i]); | |
| delay(ledDuration[i]); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment