Advertisement
Guest User

Koden

a guest
Apr 23rd, 2021
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. #include "FastLED.h"
  2.  
  3. #define LED_LEFT 8
  4. #define LED_RIGHT 9
  5. #define NUM_LEDS 17
  6.  
  7. const int ONOFF = 4;
  8. const int blinkLEFT = 3;
  9. const int blinkRIGHT = 2;
  10.  
  11. int buttonStateL = 0;
  12. int buttonStateR = 0;
  13. int engineOn = 0;
  14.  
  15.  
  16. CRGB leds[NUM_LEDS];
  17.  
  18. void setup () {
  19.    
  20.    
  21.     FastLED.addLeds<NEOPIXEL, LED_LEFT>(leds[0], NUM_LEDS);
  22.    
  23.     FastLED.addLeds<NEOPIXEL, LED_RIGHT>(leds[1], NUM_LEDS);
  24.  
  25.  
  26. fill_solid(leds[0], NUM_LEDS, CRGB::Black);
  27.  
  28. fill_solid(leds[1], NUM_LEDS, CRGB::Black);
  29.  
  30. FastLED.show();
  31.  
  32. }
  33.  
  34. void loop () {
  35.    
  36.     buttonStateL = digitalRead(blinkLEFT);
  37.     buttonStateR = digitalRead(blinkRIGHT);
  38.     EVERY_N_MILLISECONDS(1){
  39.         engineOn = digitalRead(ONOFF);
  40.     }
  41.    
  42.     if(engineOn == HIGH){
  43.    
  44.     if (buttonStateL == HIGH || buttonStateR == HIGH) {
  45.        
  46.            
  47.         if (buttonStateL == HIGH) {
  48.             for(int dot = 0; dot < NUM_LEDS; dot++){
  49.                     leds[0] [dot] = 0xff6a00;
  50.                     FastLED.show();
  51.                     delay(25);
  52.                 }
  53.         }
  54.         else if (buttonStateR == HIGH) {
  55.             for(int dot = 0; dot < NUM_LEDS; dot++){
  56.                     leds[0] [dot] = 0xff6a00;
  57.                     FastLED.show();
  58.                     delay(25);
  59.                     }
  60.         }
  61.     }
  62.    
  63.     else{
  64.         fill_solid(leds[0], NUM_LEDS, CRGB::Black);
  65.  
  66. fill_solid(leds[1], NUM_LEDS, CRGB::Black);
  67.  
  68. FastLED.show();
  69.     }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement