Introduction: 5 Programs 12V Leds Lights Organ

Soon to come our Purim party and as such we will need a light organ.
Using an Arduino i made a 5 pre programmed, speed controlled, 4 12V leds (4-pack).

Step 1: These Are the Things You Will Need :

Arduino pro mini (5v) or another arduino.
Push button
4 leds (regular)
4 4-pack 12V leds
some wires
Breadboard(s) - I like those mini breadboard you can connect together.
4 optoisolaters
Screw - Through hole connectors
220 ohm Resistor.

Step 2: Connection

Follow the sketch connecting the parts.

Keep in mind that there is a Voltage difference in the circuit, the arduino and program control parts work in 5V DC
and the 12V leds pack works, well, in 12V.
Make sure you connect the arduino itself at the RAW pin to the positive current so it would regulate it to 5V and make sure you dont mix the two so you wont be ending burning some parts.
In the sketch, except of the leds lines the Red wires are for 5V and the purple are for 12V, Blue is for ground.
Both "grounds" are the same and should be connected.

The leds are connected from pins 2 to 5, continues to the optoisolators and to ground.
The Push Buttons which is used to select the program is connected to pin 8 and also is pulled down using a 220ohm resistor to ground, and at its other leg to 5V.

The Potentiometer is connected to 5V, Ground and A0 of the arduino.

The 12V led are connected to the optoisolators which are connected at their 5V side to the leds (5V) and ground and at their 12V side to 12V, to the 12V leds and then to ground.

Step 3: Code

The "programs" array contain the pre programed programs.

The "index" integer points for the current location at the programs array.

"ledin" point for the current led turn to light.

"progSelect" keeps the selected program number (start at 0)

To add more programs you will need to increase the programs array accordingly,
to change the line "if (progSelect > 4)" to the number of programs minus one.

#define selector 6
#define speedSel A0
#define led1 2
#define led2 3
#define led3 4
#define led4 5

int Leds[4] = {led1, led2, led3, led4};
int progSelect = 0;
boolean programs[80] = {1,1,1,1,
// int cycle[4], nextCycle[4];
int ledin,index;
void setup() {
  pinMode (selector, INPUT);
  pinMode (speedSel, INPUT);
  pinMode (led1, OUTPUT);
  pinMode (led2, OUTPUT);
  pinMode (led3, OUTPUT);
  pinMode (led4, OUTPUT);
  Serial.begin (9600);
void loop() {
  for (index = pStart(progSelect); index <= pEnd (progSelect); index = index +4) {
    //for (ledin = 0; ledin <= 3; ledin ++) {
      Serial.println (progSelect);
      if (digitalRead (selector)) {
        delay (200);
        progSelect ++;
        if (progSelect > 4) {
          progSelect = 0;
      digitalWrite (led1, programs[index]);
      digitalWrite (led2, programs[index + 1]);
      digitalWrite (led3, programs[index + 2]);
      digitalWrite (led4, programs[index + 3]);
      //delay (map (analogRead (speedSel), 1, 1023, 200, 3000));
      //digitalWrite (Leds[ledin], LOW);
    delay (map (analogRead (speedSel), 1, 1023, 10, 1000));
int pStart(int PS) {
  return PS * 16;
int pEnd(int PS) {
  return PS * 16 + 16-1;

Step 4: Have a GRATE Party...

DIY Audio and Music Contest

Participated in the
DIY Audio and Music Contest