Skip to content

Instantly share code, notes, and snippets.

@vongomben
Created April 8, 2017 10:22
Show Gist options
  • Save vongomben/75b4aee8c4eaa705b8f82f7f3a2eb021 to your computer and use it in GitHub Desktop.
Save vongomben/75b4aee8c4eaa705b8f82f7f3a2eb021 to your computer and use it in GitHub Desktop.
#include "FastLED.h"
// How many leds in your strip?
#define NUM_LEDS 8
// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 3
// #define CLOCK_PIN 13
int pot = A0; // hai un pot attaccato al pin A0
int val = 0; // variabile in cui metteremo il valore del pot
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(9600);
pinMode(pot, INPUT);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loop() {
// Turn the LED on, then pause
for (int i = 0; i <= 7; i++) {
//leds[i] = 0x2C5D9D;
val = analogRead(pot);
leds[i].setHSV( val, 255, 30 * i); // per l'Hue Saturation and Value
// leds[i].setRGB( 160, 255, 30*i); // con RBG
leds[i - 1] = CRGB::Black;
leds[i + 1] = CRGB::Black;
Serial.println(val);
FastLED.show();
delay(50);
}
for (int i = 7; i >= 0; i--) {
leds[i] = CRGB::Red;
leds[i - 1] = CRGB::Black;
leds[i + 1] = CRGB::Black;
Serial.println(i);
FastLED.show();
delay(50);
}
// // Now turn the LED off, then pause
// leds[1] = CRGB::Green;
// FastLED.show();
// delay(500);
// // Now turn the LED off, then pause
// leds[1] = CRGB::Blue;
// FastLED.show();
// delay(500);
// leds[1] = CRGB::Black;
// FastLED.show();
// delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment