Created
January 8, 2022 15:00
-
-
Save fxprime/5909482cd9764ec2f2b3f6200c3f1905 to your computer and use it in GitHub Desktop.
This file contains 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
/* -------------------------------------------------------------------------- */ | |
/* WS2815 using UNO by Modulemore.com */ | |
/* -------------------------------------------------------------------------- */ | |
/* --------------------------------- Pinout --------------------------------- */ | |
// UNO ---- WS2815 | |
// D2 DI | |
// GND GND | |
#include <Arduino.h> | |
#include <FastLED.h> | |
// How many leds in your strip? | |
#define NUM_LEDS 60*4 | |
#define DATA_PIN 2 | |
// Define the array of leds | |
CRGB leds[NUM_LEDS]; | |
void setup() { | |
Serial.begin(115200); | |
Serial.println("resetting"); | |
FastLED.addLeds<WS2812B,DATA_PIN,RGB>(leds,NUM_LEDS); //สามารถใช้ WS2812B สำหรับ WS2815 ได้ | |
FastLED.setBrightness(84); //ความสว่างสูงสุด = 255 | |
} | |
void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } } | |
void loop() { | |
static uint8_t hue = 0; | |
Serial.print("x"); | |
// First slide the led in one direction | |
for(int i = 0; i < NUM_LEDS; i++) { | |
// Set the i'th led to red | |
leds[i] = CHSV(hue++, 255, 255); | |
// Show the leds | |
FastLED.show(); | |
// now that we've shown the leds, reset the i'th led to black | |
// leds[i] = CRGB::Black; | |
fadeall(); | |
// Wait a little bit before we loop around and do it again | |
delay(10); | |
} | |
Serial.print("x"); | |
// Now go in the other direction. | |
for(int i = (NUM_LEDS)-1; i >= 0; i--) { | |
// Set the i'th led to red | |
leds[i] = CHSV(hue++, 255, 255); | |
// Show the leds | |
FastLED.show(); | |
// now that we've shown the leds, reset the i'th led to black | |
// leds[i] = CRGB::Black; | |
fadeall(); | |
// Wait a little bit before we loop around and do it again | |
delay(10); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment