this post has been deleted
Please quickly edit your post.
Use the IDE Auto format tool.
Then use the IDE Copy for Forum tool on the sketch.
Lastly, paste it where your code is now.
So it looks like code, viz:
void setup() {
}
void loop() {
}
TIA
a7
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define BRIGHTNESS 255
#define NumLed_L 60
#define NumLed_R 60
#define LED_PIN_R 5
#define LED_PIN_L 6
#define RturnPin A0
#define LturnPin A1
#define brakePin A2
#define PulseLength 1050 // half of blinking period + 50 milliseconds
byte Pos = 0;
#include <FastLED.h>
CRGB ledsL[NumLed_L];
CRGB ledsR[NumLed_R];
void setup() {
FastLED.addLeds<LED_TYPE, LED_PIN_R, COLOR_ORDER>(ledsL, NumLed_L).setCorrection(TypicalLEDStrip);
FastLED.addLeds<LED_TYPE, LED_PIN_L, COLOR_ORDER>(ledsR, NumLed_R).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
pinMode(LturnPin, INPUT); // This means the pin is EPU driven
pinMode(RturnPin, INPUT);
pinMode(brakePin, INPUT);
whiteOut();
FastLED.show();
delay(1000);
}
void loop() {
static bool LturnVal = false;
static bool RturnVal = false;
static bool brakeVal = false;
static bool isTimeOut = false;
static uint32_t awaiting = 0;
if (digitalRead(RturnPin) == HIGH) {
RturnVal = true;
awaiting = millis();
}
if (digitalRead(LturnPin) == HIGH) {
LturnVal = true;
awaiting = millis();
}
brakeVal = digitalRead(brakePin) == HIGH;
Pos = (millis() % 1000UL) / 250UL;
if (millis() - awaiting > PulseLength) {
LturnVal = false;
RturnVal = false;
}
if (brakeVal)brake();
else Black();
if (LturnVal)leftTurn();
if (RturnVal)rightTurn();
if (LturnVal && RturnVal)Hazard();
FastLED.show();
}
void rightTurn() { //Right Turn Signal
//fill_solid(ledsR, NumLed_R, CRGB::Black);
for (byte i = Pos; i < NumLed_R; i += 4)ledsR[i] = CRGB::DarkOrange;
}
void leftTurn() { //Left Turn Signal
//fill_solid(ledsL, NumLed_L, CRGB::Black);
for (byte i = Pos; i < NumLed_L; i += 4)ledsL[i] = CRGB::DarkOrange;
}
void brake() {
fill_solid(ledsL, NumLed_L, CRGB::Red);
fill_solid(ledsR, NumLed_R, CRGB::Red);
}
void whiteOut() {
fill_solid(ledsL, NumLed_L, CRGB::White);
fill_solid(ledsR, NumLed_R, CRGB::White);
}
void Hazard() {
if ((millis() / 500UL) % 2) {
fill_solid(ledsL, NumLed_L, CRGB::DarkOrange);
fill_solid(ledsR, NumLed_R, CRGB::DarkOrange);
}
else Black();
}
void Black() {
fill_solid(ledsR, NumLed_R, CRGB::Black);
fill_solid(ledsL, NumLed_L, CRGB::Black);
}
Hi
is this with 2 LED strips?
thanks
Hi, how do I edit that?
Without studying your code...
You probably need separate detection of brake and blinker.
If you want to use the existing flasher circuit, you'll probably want to detect the brake and use an if-statement to run a different section of code when the brake is activated.
yes. it mentioned for a bike as regular turn signal lights replacement
click "edit post"
Is this so wise, to do your own electrical system in a car? If an accident happens because the breaklights are out, it could have devastating consequences for you and others.
but I am using only one LED strip and am using it on my car.
Can you please modify it in a way to be used on one strip please?
thanks
not if you know what you are doing.
thanks for your concern.
if you please study my code you'll see that I have already done that
It's easy to say that, but will you repeat those words if something happens?
With that said, I hope it will be ok.
It's unclear that has been established. Otherwise, you wouldn't be here.
pls do what we ask - place you code inside of Code-Tags
thank you for noting that.
already installed on my car. I am not recommending this to any one else . so use at your own risk. thanks
sorry I do not understand . I thought the code is already in quote tags.
you can.
copy your sketch,
delete code in first post,
press "code tag",
press Ctrl-V,
click "save post".
profit!
why? turn signals are never together, especially on a real car