Help for LED interrupt

I am needing to use two separate sources as a trigger or interrupt to perform a specific task.

I have an RGBW (red blue green white) led strip. I need white to be set at all times unless a power source (left or right blinker) give power and trigger the values RED 255, and GREEN 155. The code I have now isnt working quite right. I need also both left and right blinkers to be able to control two different LED strips and even at the same time.

To recap:

I have two LED RGBW strips that need to be:

constant white only

unless RIGHT Blinker or LEFT blinker are active

If they are then white should turn off and values (RED, 255) and (GREEN, 155) should activate on
the RGB diodes

How do I do this??

Just press the button.

But seriously. Without a schematic of how you have your strips and inputs connected and a copy of your existing code. Nobody has a prayer of getting anywhere near an answer for you.

Personally it’s not one of my areas of interest but if you post your schematic and your code (between [code] and [/code] tags) I’m sure someone will be able to chime in with something useful.

If you have code, then attach it so we can see it.

This doesn't sound like it needs to use interrupts. Just have the Arduino continuously looping, looking at the inputs one at a time. It can do this a few million times per second so humans won't be able to see that it's not instantaneous.

Hi, to be clear;

What you have;
Two RGBW LED Assemblies
They are setup as a set of tail lights.

You would like to;
Have both assemblies show WHITE in normal operation.
When LEFT or RIGHT indicator switch is turned ON, you want the relevant assembly to flash RED/GREEN.

Okay, if it is going to be on a road registered vehicle i don't think the RED/GREEN would be legal or are you turning RED and GREEN on together to try and get amber?

But it is possible, we need your hardware information and can you please post a copy of your sketch, using code tags.
Also can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom....... :slight_smile:

Well those values in an RGB combine to make an amber color.
And no none of this is street legal, but Its not really meant to be right now.

Heres what i got:

int leftblink = 12; // Left blinker wire
int leftblinkState = 0;
int rightblink = 13; // Right blinker wire
int rightblinkState = 0;
int power = 5;
int white = 6;// White wire
int redLeft = 7;
int greenLeft = 8;
int redRight = 9; // Red wire
int greenRight = 10; // Green wire
int blue = 11; // Blue wire

void setup() {
pinMode(power, OUTPUT);
digitalWrite(power, HIGH);
pinMode(leftblink, INPUT);
digitalWrite(leftblink, LOW);
pinMode(rightblink, INPUT);
digitalWrite(rightblink, LOW);
pinMode(white, OUTPUT);
digitalWrite(white, LOW);
pinMode(redLeft, OUTPUT);
digitalWrite(redLeft, HIGH);
pinMode(redRight, OUTPUT);
digitalWrite(redRight, HIGH);
pinMode(greenLeft, OUTPUT);
digitalWrite(greenLeft, HIGH);
pinMode(greenRight, OUTPUT);
digitalWrite(greenRight, HIGH);
pinMode(blue, OUTPUT);
digitalWrite(blue, HIGH);

}

void loop() {

leftblinkState = digitalRead(leftblink);
rightblinkState = digitalRead(rightblink);

while (leftblinkState == HIGH) {
digitalWrite(redLeft, 255);
digitalWrite(green, 155);

}

while (rightblinkState == HIGH) {
digitalWrite(redRight, 255);
analogWrite(greenRight, 155);

}

while (rightblinkState == LOW && leftblinkState == LOW) {
digitalWrite(redLeft, 0);
digitalWrite(greenLeft, 0);
digitalWrite(redRight, 0);
digitalWrite(greenRight, 0);

}
}

However nothing seems to happen.

Hi, can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?
We need to see how you are wiring up your LEDs.

Tom...... :slight_smile:

while (leftblinkState == HIGH) {
    digitalWrite(redLeft, 255);
    digitalWrite(green, 155);
   
  }

There's nothing to break you out of that loop, or indeed, any of your while loops.

Obviously a rough diagram. I made this one real quick. Im not near my desktop or id get the original.

And what type of loop could I use? Or better yet what code would make the most sense in this case? I literally just took a java course and thats the only experience I have had with programming.

And what type of loop could I use?

Not an infinite one would seem to me to be a good design choice.

I literally just took a java course

It's not too late - you can still be helped.
Java has infinite loops too, I'm sure.

bburroughs3:
Well those values in an RGB combine to make an amber color.
And no none of this is street legal, but Its not really meant to be right now.

Heres what i got:

int leftblink = 12; // Left blinker wire

int leftblinkState = 0;
int rightblink = 13; // Right blinker wire
int rightblinkState = 0;
int power = 5;
int white = 6;// White wire
int redLeft = 7;
int greenLeft = 8;
int redRight = 9; // Red wire
int greenRight = 10; // Green wire
int blue = 11; // Blue wire

void setup() {
 pinMode(power, OUTPUT);
 digitalWrite(power, HIGH);
 pinMode(leftblink, INPUT);
 digitalWrite(leftblink, LOW);
 pinMode(rightblink, INPUT);
 digitalWrite(rightblink, LOW);
 pinMode(white, OUTPUT);
 digitalWrite(white, LOW);
 pinMode(redLeft, OUTPUT);
 digitalWrite(redLeft, HIGH);
 pinMode(redRight, OUTPUT);
 digitalWrite(redRight, HIGH);
 pinMode(greenLeft, OUTPUT);
 digitalWrite(greenLeft, HIGH);
  pinMode(greenRight, OUTPUT);
 digitalWrite(greenRight, HIGH);
 pinMode(blue, OUTPUT);
 digitalWrite(blue, HIGH);

}

void loop() {

leftblinkState = digitalRead(leftblink);
 rightblinkState = digitalRead(rightblink);

while (leftblinkState == HIGH) {
   digitalWrite(redLeft, 255);
   digitalWrite(green, 155);
   
 }

while (rightblinkState == HIGH) {
   digitalWrite(redRight, 255);
   analogWrite(greenRight, 155);
   
 }
 
 while (rightblinkState == LOW && leftblinkState == LOW) {
   digitalWrite(redLeft, 0);
   digitalWrite(greenLeft, 0);
   digitalWrite(redRight, 0);
   digitalWrite(greenRight, 0);

}
}






However nothing seems to happen.

So close! Change "while" to "if" everywhere and it looks like it will work.

Hi how are you supplying power to the strip?
I hope not from the pins denoted as powerpins.
The arduino outputs cannot supply a great amount of current, anything over 40mA is basically a no no.
This LED strip, do you have a part number or model to lookup or a manual telling you what wire is which.
Does the strip have current limit resistors, what is its voltage rating?

Tom.... :slight_smile:

TomGeorge:
Hi how are you supplying power to the strip?
I hope not from the pins denoted as powerpins.
The arduino outputs cannot supply a great amount of current, anything over 40mA is basically a no no.
This LED strip, do you have a part number or model to lookup or a manual telling you what wire is which.
Does the strip have current limit resistors, what is its voltage rating?

Tom.... :slight_smile:

It's a secret!

TomGeorge:
Hi how are you supplying power to the strip?
I hope not from the pins denoted as powerpins.
The arduino outputs cannot supply a great amount of current, anything over 40mA is basically a no no.
This LED strip, do you have a part number or model to lookup or a manual telling you what wire is which.
Does the strip have current limit resistors, what is its voltage rating?

Tom.... :slight_smile:

I plan on using the board's primary power with an adapter to an in-line fuse to a fuse that only comes on when the car is on..

The strips run off of 12 volts to 24 volts safely and draw about .02 amps. It has resistors built into the strip and I plan to use MOSFETS to get the voltage I need.

AWOL:
Not an infinite one would seem to me to be a good design choice.
It's not too late - you can still be helped.
Java has infinite loops too, I'm sure.

Yeah we covered loops but Its a basic course and I missed a handful of classes. Still passed with a B but im not a computer science major. Coding is not my forte...

Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom… :slight_smile:

The strip only runs 0.02A? I think not, unless the strip only has 3 LEDs in it. And if it runs from 12 to 24V then the current will change over that voltage.

Unless you cooperate with us then you stand little chance of finding a soloution.

Grumpy_Mike:
The strip only runs 0.02A? I think not, unless the strip only has 3 LEDs in it. And if it runs from 12 to 24V then the current will change over that voltage.

Unless you cooperate with us then you stand little chance of finding a soloution.

Im giving you all I have to give. I have no CAD or images to offer. Just a sketch and a concept. And that was meant to say 1.2A per meter but in my case only about 0.8A as i am using less than a meter. Thats from the seller. But if you cant help me with what I have thats fine.

Hi, can you draw us the connections to the LED strip, if the seller is quoting a current per meter then it probably has resistors in it, what voltage is it rated at? (Sorry just saw 12 to 24V)
Or a link to where you bought the strip?

Tom..... :slight_smile:

TomGeorge:
Hi, can you draw us the connections to the LED strip, if the seller is quoting a current per meter then it probably has resistors in it, what voltage is it rated at? (Sorry just saw 12 to 24V)
Or a link to where you bought the strip?

Tom… :slight_smile:

Heres basically what I have…

It has a positive (black) and four negatives (the colored cables & white). It runs off 12volts. Thats what I would like to output. It does have built in resistors so i dont need to worry much on it. I have pushed 24 volts at 1.5A without blowing anything so its all good there. Its how to get the blinkers to cause the RGB diodes (made amber) to pulse with the blinker trigger wire.

OK so when I plug in a powered wire to act as the blinker signal it doesnt stop white and produce amber. It only makes the white brighter. Its adding power to the board and not acting like a trigger.