Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastLED.h"
- #define LED_LEFT 8
- #define LED_RIGHT 9
- #define NUM_LEDS 17
- const int ONOFF = 4;
- const int blinkLEFT = 3;
- const int blinkRIGHT = 2;
- int buttonStateL = 0;
- int buttonStateR = 0;
- int engineOn = 0;
- CRGB leds[NUM_LEDS];
- void setup () {
- FastLED.addLeds<NEOPIXEL, LED_LEFT>(leds[0], NUM_LEDS);
- FastLED.addLeds<NEOPIXEL, LED_RIGHT>(leds[1], NUM_LEDS);
- fill_solid(leds[0], NUM_LEDS, CRGB::Black);
- fill_solid(leds[1], NUM_LEDS, CRGB::Black);
- FastLED.show();
- }
- void loop () {
- buttonStateL = digitalRead(blinkLEFT);
- buttonStateR = digitalRead(blinkRIGHT);
- EVERY_N_MILLISECONDS(1){
- engineOn = digitalRead(ONOFF);
- }
- if(engineOn == HIGH){
- if (buttonStateL == HIGH || buttonStateR == HIGH) {
- if (buttonStateL == HIGH) {
- for(int dot = 0; dot < NUM_LEDS; dot++){
- leds[0] [dot] = 0xff6a00;
- FastLED.show();
- delay(25);
- }
- }
- else if (buttonStateR == HIGH) {
- for(int dot = 0; dot < NUM_LEDS; dot++){
- leds[0] [dot] = 0xff6a00;
- FastLED.show();
- delay(25);
- }
- }
- }
- else{
- fill_solid(leds[0], NUM_LEDS, CRGB::Black);
- fill_solid(leds[1], NUM_LEDS, CRGB::Black);
- FastLED.show();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement