Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FASTLED_ALLOW_INTERRUPTS 0
- #include <FastLED.h>
- #define LED_PIN 3
- #define NUM_LEDS 60
- #define BRIGHTNESS 128
- #define LED_TYPE WS2812B
- #define COLOR_ORDER GRB
- CRGB leds[NUM_LEDS];
- int value;
- int led;
- void setup() {
- delay(1000);
- FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
- FastLED.setBrightness(BRIGHTNESS);
- for (int p = 0; p <= 13; p++) {
- pinMode(p, OUTPUT);
- digitalWrite(p, 0);
- }
- Serial.begin(57600);
- }
- void loop() {
- while (Serial.available() >= 3 && Serial.read() == 0xff) {
- value = Serial.read();
- if(value == 36) {
- for(int l = 0; l < NUM_LEDS; l++) {
- if(l % 2 == 0) {
- leds[l] = CRGB::Yellow;
- } else {
- leds[l]= CRGB::Red;
- }
- }
- } else {
- leds[random(0, NUM_LEDS-1)] = CHSV(map(value, 0, 127, 0, 255), 230, 230);
- }
- }
- if (millis() % 5 == 0)
- for (int i = 0; i < NUM_LEDS; i++)
- leds[i].fadeToBlackBy(64);
- FastLED.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement