Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- // set up stuff !
- #define DATA_PIN 2
- #define CLOCK_PIN 3
- #define COLOR_ORDER GRB
- #define CHIPSET LPD8806
- #define NUM_LEDS 14
- #define FRAMES_PER_SECOND 100
- int incomingData = 0; // for incoming serial data
- int cv=1.2; //color value multiplier
- int red1=0;
- int green1=0;
- int blue1=0;
- CRGB leds[NUM_LEDS]; // make an array for the leds
- void setup() {
- delay(3000); // sanity delay
- Serial.begin(9600);
- FastLED.addLeds<CHIPSET, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS);
- FastLED.setBrightness( 55);
- }
- void loop(){
- if (Serial.available() >0){
- // look for the next valid integer in the incoming serial stream:
- int red = Serial.parseInt();
- // do it again:
- int green = Serial.parseInt();
- // do it again:
- int blue = Serial.parseInt();
- // look for the return. That's the end of your incoming string:
- if (Serial.read() == '\r') {
- // check to see which color is the higest value and increase by the color multiplier
- if ((red > green) && (red > blue)) {
- red=red*cv;
- }
- if ((blue > green) && (blue > red)) {
- blue=blue*cv;
- }
- if ((green > red) && (green > blue)) {
- green=green*cv;
- }
- //set the pixels in the stip to the colors we read in before
- for(int ledStrip = 0; ledStrip < NUM_LEDS; ledStrip = ledStrip + 1) {
- leds[ledStrip] = CRGB(red,green,blue);
- // }
- }
- }
- }
- FastLED.show();
- FastLED.delay(1000 / FRAMES_PER_SECOND);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement