Ok so I have been advised Arduino is the best product to use to power 12 LED lights (12V) via a 16 channel 12V relay board. The Leds are Techna 12Volt panel LED's.
Each LED needs to power on at random for 2 seconds, this needs to be on a continuos loop.
2 Questions
Will the arduino have enough outputs to control 12 LEDS through the relay board
If you want someone to write a program for you please ask in the Gigs and Collaborations section of the Forum and be prepared to pay.
If you want to learn to program yourself the examples that come with the Arduino IDE are a good place to start. There are also many online tutorials. Also see the Useful Links Thread.
If you want more advice please post a link to the datasheet for your relay board.
frankandbeanz:
Each LED needs to power on at random for 2 seconds, this needs to be on a continuos loop.
What would the code be for this project.
You will have to be a LOT more specific when designing the sketch.
Are the lights on one at a time?
Is there delay between one light going off and the next light going on?
Is it the same 'random' pattern each loop?
Does the 'random' pattern have to go through all 12 lights before looping?
That should be " lastLED = randomNum;" in place of " lastLED = rand;"
There is also a problem using "NUM_LEDS + 1" as the upper limits on random. That will give you the 13th element of a 12-element array.
const byte NUM_LEDS = 12;
const unsigned long TMR_CHANGEUP = 2000; //2000mS
const byte LEDPins[NUM_LEDS] =
{
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
};
// Relay modules are typically Active Low: A LOW signal
// turns them ON and a HIGH signal turns them OFF.
const bool RELAY_OFF = HIGH;
const bool RELAY_ON = LOW;
unsigned long TimeThen;
byte LastLED;
void setup()
{
for (byte i = 0; i < NUM_LEDS; i++ )
{
pinMode(LEDPins[i], OUTPUT );
digitalWrite(LEDPins[i], RELAY_OFF );
}//for
randomSeed(analogRead(A0)); // Leave A0 floating to get some entropy
//select a random LED and turn it on
byte thisLED = LEDPins[random(NUM_LEDS)];
digitalWrite(thisLED, RELAY_ON);
LastLED = thisLED;
TimeThen = millis();
}//setup
void loop()
{
unsigned long timeNow = millis();
if ( (timeNow - TimeThen) > TMR_CHANGEUP )
{
TimeThen = TimeThen + TMR_CHANGEUP;
byte thisLED = LEDPins[random(NUM_LEDS)];
digitalWrite(LastLED, RELAY_OFF);
digitalWrite(thisLED, RELAY_ON);
LastLED = thisLED;
}//if
}//loop