Light-OH

Light-OH © GPL3+

It is an amazing RGB LED light. It will be reacting on the music and will be showing colorful lights.

  • 4,483 views
  • 1 comment
  • 14 respects

Components and supplies

About this project

HOLA!

We are two students of Engineering Product Design, Marco and Jose. This is our first approach to Arduino and this project has been a way to improve the knowledge of the programming language and touch some electronic component by hand.

We were interested in experimenting with music and light so we came out with this simple idea: play music with a speaker and generate a lighting response.

At the end we made it, and the effect is nice while it is standing on the desk when music it is playing.

List of material

These are the main components we use to realize the project:

  • 1x Arduino UNO
  • 1x Microphone sound sensor module KY-038
  • 1x Adafruit NeoPixel Digital RGB LED Strip - White 30 LED
  • 1x SparkFun PushButton switch 12mm
  • 12x Jumper wires (generic)
  • 1x Breadboard (generic)
  • 2x Resistor 221 ohm

We alse used the following items:

  • A small strip of methacrylate
  • A wood stick Ø3x40cm
  • A wood box
  • Hot Glue Gun

STEP 1: Wiring

The first step is to wire the Arduino and the breadboard with the components as shown in the pictures below.

STEP 2: Uploading the code to the Arduino

Once you have to upload the code below to your Arduino.

STEP 3: Video

Code

Light-OH.ino.inoArduino
//Light-OH Arduino code
//The used microphone substracts values to the noise when sound increases, so the more sound it gets, the smaller the noise

#include <Adafruit_NeoPixel.h> //Neopixel library loading

#define BUTTON_PIN 9 // Button pin
#define MIC_PIN A0 // Microphone pin
#define LED_PIN 3 // NeoPixel LED strip pin
#define N_PIXELS 30 // Number of pixels in LED strip

Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_PIXELS, LED_PIN, NEO_GRB + NEO_KHZ800); //Neopixel strip declaration

int NSAMPLES = 30; //Number of samples the microphone takes
int samples = 0; //Samples initialization and starting value
int noise = 0; //Noise initialization and starting value
int RED = 0; //Red color initialization and starting value
int GREEN = 0; //Green color initialization and starting value
int BLUE = 0; //Blue color initialization and starting value

int buttonState = 0;


// the setup routine runs once when you press reset:
void setup() {
  Serial.begin(9600); // Initialize serial communication at 9600 bits per second
  strip.begin(); // Initialize LED strip
  strip.show(); // Initialize all pixels to 'off'

  samples = NSAMPLES; //Declare value of "samples"
  pinMode(BUTTON_PIN, INPUT);

}

// the loop routine runs over and over again forever:
void loop() {
  buttonState = digitalRead(BUTTON_PIN);
  while (MODE<2){
    if (buttonState == LOW) {
      // turn LED on:
      MODE = MODE + 1;
    }
  } else {
    MODE = 0;
  }

  //Process to get the "noise" value according to the taken samples:
  if (samples > 0) {
    noise = noise + abs(analogRead(A0) + 22);
    samples = samples - 1;
  } else {
    noise = noise / NSAMPLES;
    samples = NSAMPLES;

    Serial.println(noise); //Noise value visualization in order to calibrate the microphone

    updatePixels(noise, RED, GREEN, BLUE); //Call to updatePixels function
    delay(20); //Delay of 20 miliseconds between pixels illumination

  }

//Color declaration depending on the noise value. This is useful to change pixels colors in an easy way:
  if (noise < 570) {
    RED = 0;
    GREEN = 50;
    BLUE = 0;
  }
  if (noise < 550) {
    RED = 50;
    GREEN = 50;
    BLUE = 0;
  }
  if (noise < 540) {
    RED = 50;
    GREEN = 0;
    BLUE = 0;
  }
}

//Pixel control function. It makes pixels illuminate depending on the noise value (yes, it's a bit long):
void updatePixels(int noise, int RED, int GREEN, int BLUE) {
  if (noise < 566) {
    strip.setPixelColor(0, RED, GREEN, BLUE); // Meaning: (number of pixel to illuminate, red color value, green color value, blue color value)
  } else {
    strip.setPixelColor(0, 0, 0, 0); // And finally this sets all pixels to off if there's no noise in the room
  }
  if (noise < 565.5) {
    strip.setPixelColor(1, RED, GREEN, BLUE);
    strip.setPixelColor(2, RED, GREEN, BLUE);

  } else {
    strip.setPixelColor(1, 0, 0, 0);
    strip.setPixelColor(2, 0, 0, 0);
  }
  if (noise < 565) {
    strip.setPixelColor(3, RED, GREEN, BLUE);
    strip.setPixelColor(4, RED, GREEN, BLUE);

  } else {
    strip.setPixelColor(3, 0, 0, 0);
    strip.setPixelColor(4, 0, 0, 0);

  }
  if (noise < 564.5) {
    strip.setPixelColor(5, RED, GREEN, BLUE);
    strip.setPixelColor(6, RED, GREEN, BLUE);

  } else {
    strip.setPixelColor(5, 0, 0, 0);
    strip.setPixelColor(6, 0, 0, 0);

  }
  if (noise < 564) {
    strip.setPixelColor(7, RED, GREEN, BLUE);
    strip.setPixelColor(8, RED, GREEN, BLUE);

  } else {
    strip.setPixelColor(7, 0, 0, 0);
    strip.setPixelColor(8, 0, 0, 0);

  }
  if (noise < 563.5) {
    strip.setPixelColor(9, RED, GREEN, BLUE);
    strip.setPixelColor(10, RED, GREEN, BLUE);

  } else {
    strip.setPixelColor(9, 0, 0, 0);
    strip.setPixelColor(10, 0, 0, 0);

  }
  if (noise < 563) {
    strip.setPixelColor(11, RED, GREEN, BLUE);
    strip.setPixelColor(12, RED, GREEN, BLUE);

  } else {
    strip.setPixelColor(11, 0, 0, 0);
    strip.setPixelColor(12, 0, 0, 0);

  }
  if (noise < 562.5) {
    strip.setPixelColor(13, RED, GREEN, BLUE);
    strip.setPixelColor(14, RED, GREEN, BLUE);

  } else {
    strip.setPixelColor(13, 0, 0, 0);
    strip.setPixelColor(14, 0, 0, 0);

  }
  if (noise < 562) {
    strip.setPixelColor(15, RED, GREEN, BLUE);
    strip.setPixelColor(16, RED, GREEN, BLUE);

  } else {
    strip.setPixelColor(15, 0, 0, 0);
    strip.setPixelColor(16, 0, 0, 0);

  }
  if (noise < 561.5) {
    strip.setPixelColor(17, RED, GREEN, BLUE);
    strip.setPixelColor(18, RED, GREEN, BLUE);

  } else {
    strip.setPixelColor(17, 0, 0, 0);
    strip.setPixelColor(18, 0, 0, 0);

  }
  if (noise < 561) {
    strip.setPixelColor(19, RED, GREEN, BLUE);
    strip.setPixelColor(20, RED, GREEN, BLUE);

  } else {
    strip.setPixelColor(19, 0, 0, 0);
    strip.setPixelColor(20, 0, 0, 0);

  }
  if (noise < 560.5) {
    strip.setPixelColor(20, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(20, 0, 0, 0);
  }
  if (noise < 560) {
    strip.setPixelColor(11, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(11, 0, 0, 0);
  }
  if (noise < 553) {
    strip.setPixelColor(12, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(12, 0, 0, 0);
  }
  if (noise < 552) {
    strip.setPixelColor(13, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(13, 0, 0, 0);
  }
  if (noise < 551) {
    strip.setPixelColor(14, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(14, 0, 0, 0);
  }
  if (noise < 550) {
    strip.setPixelColor(15, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(15, 0, 0, 0);
  }
  if (noise < 549) {
    strip.setPixelColor(16, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(16, 0, 0, 0);
  }
  if (noise < 548) {
    strip.setPixelColor(17, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(17, 0, 0, 0);
  }
  if (noise < 547) {
    strip.setPixelColor(18, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(18, 0, 0, 0);
  }
  if (noise < 546) {
    strip.setPixelColor(19, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(19, 0, 0, 0);
  }
  if (noise < 545) {
    strip.setPixelColor(20, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(20, 0, 0, 0);
  }
  if (noise < 544) {
    strip.setPixelColor(21, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(21, 0, 0, 0);
  }
  if (noise < 543) {
    strip.setPixelColor(22, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(22, 0, 0, 0);
  }
  if (noise < 542) {
    strip.setPixelColor(23, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(23, 0, 0, 0);
  }
  if (noise < 541) {
    strip.setPixelColor(24, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(24, 0, 0, 0);
  } if (noise < 540) {
    strip.setPixelColor(25, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(25, 0, 0, 0);
  }
  if (noise < 539) {
    strip.setPixelColor(26, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(26, 0, 0, 0);
  }
  if (noise < 538) {
    strip.setPixelColor(27, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(27, 0, 0, 0);
  }
  if (noise < 537) {
    strip.setPixelColor(28, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(28, 0, 0, 0);
  }
  if (noise < 536) {
    strip.setPixelColor(29, RED, GREEN, BLUE);
  } else {
    strip.setPixelColor(29, 0, 0, 0);
  }
  strip.show();


}

Schematics

proyecto_arduino_sketch_F61RwPprgu.jpg
Proyecto arduino sketch f61rwpprgu

Comments

Similar projects you might like

Animating an LED strip from a computer

Project showcase by kendfrey

  • 26,157 views
  • 16 comments
  • 97 respects

Play Polyphonic Tones!

by nathan_ramanathan

  • 12,775 views
  • 18 comments
  • 22 respects

Electronic Piano Keyboard With Preset Songs

Project tutorial by Lindsay Fox

  • 92,423 views
  • 68 comments
  • 186 respects

Buzzer Alarm System With Help Of Arduino

by Team ONYX

  • 62,118 views
  • 10 comments
  • 38 respects

Unravel Preset Piano Easy Arduino (Even a Ghoul Can Make It)

Project in progress by ExeCuteLi

  • 15,166 views
  • 12 comments
  • 32 respects

Morse Code Communication Using Arduino

Project tutorial by Jalal Mansoori

  • 19,667 views
  • 19 comments
  • 36 respects
Add projectSign up / Login