Hi all, sorry for this post (I know it probably seems stupid).
This is my first ever Arduino project, I have no idea what I am doing and I'm hoping for some help.
I'm a volunteer firefighter and I'm trying to make a 6 LED traffic advisor for my car using an arduino uno R3 and 6 relays (one for each LED set). I'd like it to have 4 modes, each controlled via it's own button. The buttons are latching, so I need to pattern to repeat aslong as the button is pressed
Mode 1: Left, lights start on the right and make their way to the left
Mode 2: Right, lights start on the left and make their way to the right
Mode 3: Center out, this one is pretty self explanatory, the middle 2 lights turn on, then go out to the end of each side (6 lights in total)
Mode 4: Alert, just a general flashing pattern, hoping for an even/odd style one ("_" light off, "^" light on). Flashing between _ ^ _ ^ _ ^ and ^ _ ^ _ ^ _
These are the inputs to my relays:
Hopefully this makes some sense and yall can help me.
Thank you!
Well let's first make sure you have things wired correctly, so you don't burn out your UNO.
Post the data sheet for or link to the relay board you have.
Yep, I've got one of those, I'm still waiting on the board to arrive, it should be here in a couple of days, I'm hoping to get everything setup (or nearly setup), so when it arrives, it's basically plug 'n' play
I don't know about plug and play but we should be able to make it work.
Do you have some LEDs and resistors you can connect to the relays to see when they turn on?
Sure, 5 is OK for now
Here is how to connect the relay board to the Uno.
I show an 8 channel and I only show 1 LED but the other 5 should be wired the same way
The important thing is to remove that yellow jumper and connect 12V as shown
Of cource you will also need to add 4 buttons
const int RELAY_PIN1 = 13; // The Arduino pin, which connects to the relay IN1 pin
void setup()
{
// initialize digital pin as an output.
pinMode(RELAY_PIN1, OUTPUT);
}
// the loop function runs over and over again forever
void loop()
{
// This will turn the relay ON for two seconds
// then OFF for two seconds
digitalWrite(RELAY_PIN, HIGH);
delay(2000);
digitalWrite(RELAY_PIN, LOW);
delay(2000);
}
Spent a few hours and now everything is working perfectly on my bench, thanks so much for your help. How would you recommend that I power my arduino inside my car? I don't want to accidentially cook it. Cheers!
You have 12V for the relays, so connect that to the barrel connector on the Uno.
Make sure you get the polarity right.
One like shown below. 5.5mm x 2.1mm male
Buy on amazon, ebay adafruit, digikey etc