This is my first project. I want to have two led strips mimic my turn signals/brake lights. I have two WS2812B with 24 led’s, Adafruit 5v Trinket. The led’s are set up in an array using pins 3 and 4. I want to use the signals from the bike to trigger the brake/ turn signals. On my motorcycle the turn signals and brake lights are always on for safety. When they are “active” the motorcycle lights appear go from half brightness to full brightness. I want the led strips to do the same, when the running light are on I want the brightness to be ½ of the max value. When the brakes or turn signals are active I want the led’s to toggle from half brightness to full brightness and not on and off like the blink sketch.
I was wanting to know how I could set up the brightness for half brightness and full brightness, and how I could use those values in an “if/else”.
I probably have more questions and have not realized them yet. If anyone sees any problems feel free to point them out. This is a learning experience for me.
// MultiArrays - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on
// using multiple controllers. In this example, we're going to set up two WS2812B strips on two
// different pins, each strip getting its own CRGB array to be played with
#include <FastLED.h>
#define NUM_LEDS_PER_STRIP 24
#define LED_TYPE WS2812B
int BRIGHTNESS = 127;
int fullBRIGHTNESS = 255;
#define COLOR_ORDER GRB
#define FRAMES_PER_SECOND 60
#define leftPin 0
#define rightPin 1
#define brakePin 2
CRGB leftLeds[NUM_LEDS_PER_STRIP];
CRGB rightLeds[NUM_LEDS_PER_STRIP];
// For mirroring strips, all the "special" stuff happens just in setup. We
// just addLeds multiple times, once for each strip
void setup() {
delay(3000); // sanity delay
pinMode(leftPin, INPUT_PULLUP); //Input pin from left turn signal
pinMode(rightPin, INPUT_PULLUP); //Input pin from right turn signal
pinMode(brakePin, INPUT_PULLUP); //Input pin from brakes
// tell FastLED there's 24 WS2812B leds on pin 3
FastLED.addLeds<WS2812B, 3>(leftLeds, NUM_LEDS_PER_STRIP);
// tell FastLED there's 24 WS2812B leds on pin 4
FastLED.addLeds<WS2812B, 4>(rightLeds, NUM_LEDS_PER_STRIP);
FastLED.setBrightness( BRIGHTNESS );
}
void loop() {
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
// set our current dot to red
leftLeds[i] = CRGB::Red;
rightLeds[i] = CRGB::Red;
FastLED.show();
// clear our current dot before we move on
leftLeds[i] = CRGB::Black;
rightLeds[i] = CRGB::Black;
delay(100);
}
if (digitalRead(leftPin) == LOW) {
}
else {
}
analogWrite(CRGB leftLeds, BRIGHTNESS);
delay( 50 );
}
if (digitalRead(rightPin) == low) {
}
else {
}
analogWrite(CRGB rightLeds, BRIGHTNESS);
delay( 50 );
}
if (digitalRead(brakePin) == LOW) {
}
else {
}
analogWrite(CRGB rightLeds, CRGB leftLeds. BRIGHTNESS);
delay( 50 );
}
}