Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //FastLED_AnalougeInput.ino
- #include <FastLED.h>
- #define LED_PIN 13 // which ping are LEDS connected to?
- #define NUM_LEDS 250
- #define COLOR_ORDER RGB
- #define LED_TYPE WS2811
- #define MAX_BRIGHTNESS 255 // watch the power!
- const int brightnessInPin = A0; // Analog input pin that the potentiometer is attached to
- const int speedInPin = A1; // Analog input pin that the potentiometer is attached to
- struct CRGB leds[NUM_LEDS];
- void setup() {
- delay(3000); // in case we do something stupid.
- LEDS.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
- FastLED.setBrightness(MAX_BRIGHTNESS);
- }
- void loop() {
- // read the analog brightness value:
- int brightValue = analogRead(brightnessInPin);
- // map it to the range of the FastLED brightness:
- int outputValue = map(brightValue, 0, 1023, 0, 255);
- // now set the brightness of the strip
- FastLED.setBrightness(outputValue)
- // read the analog speed value:
- int speedValue = analogRead(speedInPin);
- // map it to a value used in delay();
- int delayValue = map(speedValue, 0, 1023, 10, 300);
- // First slide the led in one direction
- for(int i = 0; i < NUM_LEDS; i++) {
- // Set the i'th led to red
- leds[i] = CRGB::Red;
- // Show the leds
- FastLED.show();
- // now that we've shown the leds, reset the i'th led to black
- leds[i] = CRGB::Black;
- // Wait a little bit before we loop around and do it again
- delay(delayValue);
- }
- // Now go in the other direction.
- for(int i = NUM_LEDS-1; i >= 0; i--) {
- // Set the i'th led to red
- leds[i] = CRGB::Red;
- // Show the leds
- FastLED.show();
- // now that we've shown the leds, reset the i'th led to black
- leds[i] = CRGB::Black;
- // Wait a little bit before we loop around and do it again
- delay(delayValue);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement