Hi I'm new to arduino and coding in general and need some help..
I am currently running a ardunio nano with 4 ws2812b strips, each with 15 leds as bicycle indicators.
- 2 for the front; always running white light
- 2 for the back; always running red light
added 2 tactile switches(off(on); 6x6x5mm); one for each handle
- push left switch: FrontLeft/BackLeft goes alternating white/red to orange and back
- push right switch: FrontRight/BackRight goes alternating white/red to orange and back
and here is where i'm stuck.. i want to add a 3rd button to change through some brightness modes but keep my code for the blinking
like
mode1 front brightness 100%/back brightness 100%/orange brightness 100%
mode2 front brightness 80%/back brightness 80%/orange brightness 100%
mode3 front brightness 40%/back brightness 50%/orange brightness 100%
mode4 front brightness 0%/back brightness 50%/orange brightness 100%
i've set my max_bright = 192 i knew its not max but my 100%
maybe someone even knows how to get some indicator running light; stuck on that aswell
https://forum.arduino.cc/index.php?topic=550283.0
lesept
How about this ?
helped me with his knowledge on this project to build "my" code but now i'm stuck and need help
#include <FastLED.h>
#define PIN_STRIP1 6
#define PIN_STRIP2 7
#define PIN_STRIP3 8
#define PIN_STRIP4 9
#define PIN_BUTTON1 2
#define PIN_BUTTON2 3
#define COLOR_ORDER GRB
#define LED_TYPE WS2812B
#define NUM_LEDS 15
uint8_t max_bright = 192; //guess that needs to be gone when the modes work
CRGB leds1[NUM_LEDS];
CRGB leds2[NUM_LEDS];
CRGB leds3[NUM_LEDS];
CRGB leds4[NUM_LEDS];
void setup() {
LEDS.addLeds<LED_TYPE, PIN_STRIP1, COLOR_ORDER>(leds1, NUM_LEDS).setCorrection( TypicalLEDStrip );
LEDS.addLeds<LED_TYPE, PIN_STRIP2, COLOR_ORDER>(leds2, NUM_LEDS).setCorrection( TypicalLEDStrip );
LEDS.addLeds<LED_TYPE, PIN_STRIP3, COLOR_ORDER>(leds3, NUM_LEDS).setCorrection( TypicalLEDStrip );
LEDS.addLeds<LED_TYPE, PIN_STRIP4, COLOR_ORDER>(leds4, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness(max_bright);
pinMode(PIN_BUTTON1, INPUT_PULLUP);
pinMode(PIN_BUTTON2, INPUT_PULLUP);
}
void loop() {
fill_solid(leds1, NUM_LEDS, CRGB::White);
fill_solid(leds2, NUM_LEDS, CRGB::White);
fill_solid(leds3, NUM_LEDS, CRGB::Red);
fill_solid(leds4, NUM_LEDS, CRGB::Red);
Checkbuttons();
FastLED.show();
FastLED.clear();
}
void Checkbuttons()
{
bool StateB1 = digitalRead(PIN_BUTTON1);
bool StateB2 = digitalRead(PIN_BUTTON2);
if (!StateB1) ChangeStrip1 ();
if (!StateB2) ChangeStrip2 ();
if (!StateB1 and !StateB2) ChangeStrip3 ();
}
void ChangeStrip1 () {
for (int i = 0; i < 4; i++) {
fill_solid(leds3, NUM_LEDS, CRGB::Gold);
fill_solid(leds1, NUM_LEDS, CRGB::Gold);
FastLED.show();
delay(400);
fill_solid(leds3, NUM_LEDS, CRGB::Red);
fill_solid(leds1, NUM_LEDS, CRGB::White);
FastLED.show();
delay(250);
FastLED.show();
}
}
void ChangeStrip2 () {
for (int i = 0; i < 4; i++) {
fill_solid(leds4, NUM_LEDS, CRGB::Gold);
fill_solid(leds2, NUM_LEDS, CRGB::Gold);
FastLED.show();
delay(400);
fill_solid(leds4, NUM_LEDS, CRGB::Red);
fill_solid(leds2, NUM_LEDS, CRGB::White);
FastLED.show();
delay(250);
FastLED.show();
}
}
void ChangeStrip3 () {
for (int i = 0; i < 900; i++){
for (int i = 0; i < 8; i++) {
fill_solid(leds3, NUM_LEDS, CRGB::Gold);
fill_solid(leds1, NUM_LEDS, CRGB::Gold);
fill_solid(leds4, NUM_LEDS, CRGB::Gold);
fill_solid(leds2, NUM_LEDS, CRGB::Gold);
FastLED.show();
delay(400);
fill_solid(leds4, NUM_LEDS, CRGB::Red);
fill_solid(leds2, NUM_LEDS, CRGB::White);
fill_solid(leds3, NUM_LEDS, CRGB::Red);
fill_solid(leds1, NUM_LEDS, CRGB::White);
FastLED.show();
delay(250);
FastLED.show();
}
for (int i = 0; i < 15; i++) {
fill_solid(leds4, NUM_LEDS, CRGB::Blue);
fill_solid(leds2, NUM_LEDS, CRGB::Blue);
fill_solid(leds3, NUM_LEDS, CRGB::Blue);
fill_solid(leds1, NUM_LEDS, CRGB::Blue);
FastLED.show();
delay(100);
fill_solid(leds4, NUM_LEDS, CRGB::Red);
fill_solid(leds2, NUM_LEDS, CRGB::White);
fill_solid(leds3, NUM_LEDS, CRGB::Red);
fill_solid(leds1, NUM_LEDS, CRGB::White);
FastLED.show();
delay(50);
fill_solid(leds4, NUM_LEDS, CRGB::Blue);
fill_solid(leds2, NUM_LEDS, CRGB::Blue);
fill_solid(leds3, NUM_LEDS, CRGB::Blue);
fill_solid(leds1, NUM_LEDS, CRGB::Blue);
FastLED.show();
delay(100);
fill_solid(leds4, NUM_LEDS, CRGB::Red);
fill_solid(leds2, NUM_LEDS, CRGB::White);
fill_solid(leds3, NUM_LEDS, CRGB::Red);
fill_solid(leds1, NUM_LEDS, CRGB::White);
FastLED.show();
delay(100);
FastLED.show();
}
for (int i = 0; i < 8; i++) {
fill_solid(leds3, NUM_LEDS, CRGB::Gold);
fill_solid(leds1, NUM_LEDS, CRGB::Gold);
fill_solid(leds4, NUM_LEDS, CRGB::Gold);
fill_solid(leds2, NUM_LEDS, CRGB::Gold);
FastLED.show();
delay(400);
fill_solid(leds4, NUM_LEDS, CRGB::Red);
fill_solid(leds2, NUM_LEDS, CRGB::White);
fill_solid(leds3, NUM_LEDS, CRGB::Red);
fill_solid(leds1, NUM_LEDS, CRGB::White);
FastLED.show();
delay(250);
FastLED.show();
}
}
}
if someone can share his knowledge with me, it would mean a lot to me and my powerbank who's getting worn out ..
thanks in advance M

