Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // an array of the LED pin numbers
- // change this to match your LED pins
- int led_pins[] = {7, 6, 5};
- void setup()
- {
- Serial.begin(115200);
- delay(2500); // ensure Serial is ready
- Serial.println("READY");
- // if you have an array of LED pins you can use
- // it to set all LED pin modes as OUTPUT
- for (int i=0; i < 3; ++i)
- {
- pinMode(led_pins[i], OUTPUT);
- }
- }
- void loop()
- {
- // you would normally do this on the button push
- int result = millis() % 3;
- Serial.print(result); // DEBUG print
- // turn off any LED that might be on and show
- // the newly selected LED
- for (int i=0; i < 3; ++i)
- {
- digitalWrite(led_pins[i], LOW);
- }
- digitalWrite(led_pins[result], HIGH);
- Serial.print(", turn on LED at pin ");
- Serial.println(led_pins[result]);
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement