We got an assignment in school to think of, find or create a project that had with arduino to do and what i came up with was that i was going to build a light system for my new computer chassi since it was a pretty simple project and it could be made easier or more difficult depending on how it was going for me.

For this project I’m going to be using the arduino and for more experienced arduino users this tutorial will probably be pretty dull because I’m trying to explain it so that anyone even people who don’t know how to use an arduino can make this.

Step 1: Parts

1 Arduino Uno rev3
1 Breadboard
3 Transistors
1 Bluetooth Chip  JY-MCU bt board
A couple of cables

Step 2: LED and Transistor Explanation

How the LEDs work
The sort of leds that i got for this project were different than the ones i was used to so i had to figure out how they work. It turns out that instead of controlling which leg the power comes in to you have to control how much power that can flow out of each leg/for each color instead. For this i had to use transistors.

How transistors work
The transistors have 3 feet and one is “In” anode, one is “out” catode and one is “control”.
The more power/ the stronger signal strength sent to the “control” pin the more power the transistor will let through.
What the transistor does in this case is that it limits how much power can flow through it from the GND on the LED and that way we can change the strength of each colour in the LED.

Step 3: Connecting the Arduino, Breadboard and LEDs

First of you should make a 5V and a GND lane on the breadboard (for ease of use). Do this by connecting the 5V connector on the arduino to the top lane (Look at the picture) and the GND connector on the arduino to the second lane on the breadboard.
Then you have to decide where you want to connect your LEDs or at least the cables for the LEDs if you don’t want them straight on the breadboard. When you’ve done that connect the (in my case) longest pin on the LED which is the 5V pin where the power goes in, to the 5V lane on the breadboard. (With a resistor if your led can’t handle 5V)

Step 4: Connecting the Transistors

Plug in the transistors. In my case the anode part is on the top of the connector if the half circle is pointed to the left, the middle one is the signal and the right one is GND.
Connect the transistors anode leg to the LED, one to each leg/colour of the LED.
(I had to extend the blue (second from the left) pin onto the left side with a cable so the blue one is actually at the far right.)

Step 5: Connecting the Cables

Now you need to connect the middle pin of the transistor to the desired pins and check which leg is for which colour on the LED. On mine it’s Red, Blue, anode, Green from the left to right if you have the longest pin towards the right side (look at the picture)
In this example I’m using pin 9 for Green, 10 for Blue and 11 for Red so I’ve connected the corresponding transistor to the right led pin and arduino pin.

Step 6: Programming

For my program i used the switch example ( http://www.arduino.cc/en/Tutorial/SwitchCase2 ) and modified it a bit.

  Switch statement  with serial input

Demonstrates the use of a switch statement.  The switch
statement allows you to choose from among a set of discrete values
of a variable.  It's like a series of if statements.

To see this sketch in action, open the Serial monitor and send any character.
The characters a, b, c, d, and e, will turn on LEDs.  Any other character will turn
the LEDs off.

The circuit:
* 5 LEDs attached to digital pins 2 through 6 through 220-ohm resistors

This is a modified version of the Swith Case 2 example from the arduino.cc website. ( http://www.arduino.cc/en/Tutorial/SwitchCase2 )
  int analogOutPinG = 9;
  int analogOutPinB = 10;
  int analogOutPinR = 11;

void setup() {
  // initialize serial communication:
   // initialize the LED pins:
        pinMode(analogOutPinG, OUTPUT);
        pinMode(analogOutPinB, OUTPUT);
        pinMode(analogOutPinR, OUTPUT);

void loop() {
  // read the sensor:
  if (Serial.available() > 0) {
    int inByte = Serial.read();
    // do something different depending on the character received. 
    // The switch statement expects single number values for each case;
    // in this exmaple, though, you're using single quotes to tell
    // the controller to get the ASCII value for the character.  For
    // example 'a' = 97, 'b' = 98, and so forth:

    switch (inByte) {
    case 'a':   
  analogWrite(analogOutPinG, 255);
  analogWrite(analogOutPinB, 0);
  analogWrite(analogOutPinR, 0);
    case 'b':   
  analogWrite(analogOutPinG, 255);
  analogWrite(analogOutPinB, 220);
  analogWrite(analogOutPinR, 0);
    case 'c':   
  analogWrite(analogOutPinG, 0);
  analogWrite(analogOutPinB, 255);
  analogWrite(analogOutPinR, 0);
    case 'd':   
  analogWrite(analogOutPinG, 0);
  analogWrite(analogOutPinB, 200);
  analogWrite(analogOutPinR, 255);
    case 'e':   
  analogWrite(analogOutPinG, 0);
  analogWrite(analogOutPinB, 0);
  analogWrite(analogOutPinR, 255);
      case 'f':   
  analogWrite(analogOutPinG, 200);
  analogWrite(analogOutPinB, 0);
  analogWrite(analogOutPinR, 255);
    case 'g':   
  analogWrite(analogOutPinG, 120);
  analogWrite(analogOutPinB, 0);
  analogWrite(analogOutPinR, 255);
      case 'h':   
  analogWrite(analogOutPinG, 0);
  analogWrite(analogOutPinB, 0);
  analogWrite(analogOutPinR, 0);

Step 7: Testing

To test if you’ve done everything correctly connect your arduion via usb to your computer and upload the code to your arduino then open up the serial monitor (button with a magnifier on the top right of the arduino program) and type “a” then send it.
The light should light up green. If you want to try some more send the letters from “a” to “g”
the led should light up in different colours.
If it doesn’t work check so that the cables are all plugged in correctly, that the program has been uploaded and that there’s no shortage in the wiring.

Step 8: Adding a Bluetooth Chip

To add the bluetooth chip you just need to do a couple of simple steps.
Connect it’s VCC pin to the 5V lane on the breadboard.
Connect it’s GND pin to the ground lane on the bradboard.
Connect the RX pin to the TX pin on the arduino (on the far left) and the TX pin on the bluetooth chip to the RX on the arduino.

Step 9: Testing the Bluetooth

To test if the bluetooth chip works first check that the light on it is blinking, this indicates that is had power but is not connected to any device.
Then you’ll have to download some sort of serial over bluetooth software for your computer (if you have bluetooth on it) or for your phone which is what i have done.
I have an android phone so i downloaded the “Bluetooth spp tools pro” for free on the google play store. When you start the app it automatically starts searching for bluetooth devices that it can connect to and the factory name for my bluetooth chip was “linvor”. When you’ve connected to your bluetooth chip with your device you can start trying it right away, just sent any letter between “a-g” and the LED on your breadboard should change colour.

Step 10: Final Result

Step 11: Ideas for Continuing the Project

I do plan on continuing this project next semester and the ideas i have for that is for example making the lights sound reactive so that red for example glowed stronger when there was a lot of bass in a song and maybe yellow when there is a lot of high tones.
And I’ve also thought about putting a wifi shield on my arduino so i can be able to change the colour from a website.
Do you know if there is anyway you could a Dip switch to change the color of the leds, instead of the bluetooth? <br> <br>Thanks, great tutorial!

About This Instructable




More by Mathiasaa:Bluetooth controlled chassi lights 
Add instructable to: