Picture of Tinee9: RGB LED Module

*Tiny9 or Tinee9 are the same company just working out the kinks in the business name.

*Please subscribe/follow my blog.

*This instructable is considered a beginner level tutorial with some knowledge of software. (Ardruino)

*Caution LED light is bright and may give eye irritation to though who are sensitive to bright light.

Step 1: The RGB LED

Picture of The RGB LED
Picture of The RGB LED

The RGB LED is what it sounds like:

R: Red

G: Green

B: Blue

L: Light

E: Emitting

D: Diode

A RGB LED will emit Red, Green, or Blue, or all or a mix of the colors at once.

Today we are going to combine the LIS2HH12 Accelerometer with the RGB LED module and make the LED turn colors depending on which angle we have achieved.

Little Bits 

Star Wars Droid Inventor Kit

Step 2: Materials

Picture of Materials

Materials you need for this instructable are:

You can find the items at this location-KIT and KIT2

Items from this instructable ->Accelerometer:

Arduino nano

LIS2HH12 3-Axis Accelerometer

RGB LED Module

24 AWG wire

100 Ohm Resistor

2x 1Kohm Resistor

Wire Strippers

Breadboard

Step 3: Setup

Picture of Setup

First you need to set up the breadboard like in this instructable here.

Once you have set up the breadboard like this, then we place the RGB LED next to the Accelerometer.

Once placed Jumper the pin called 3.3 to the red row on the breadboard.

Next, Using wire strippers cut the 24 AWG wire into 3 strips of 3 inch wire. Strip the ends of the wire.

Now jumper Pin called R on RGB LED to Arduino Pin D2

Jumper Pin called B on LED to Arduino Pin D3

Jumper Pin called G on LED to Arduino Pin D4

*No, the Pins R, G, B on LED do not mean you turn OFF Pin D4 to turn on the Green LED. Sorry for the confusion will be fixed on the next rev of the LED.

Step 4: Open Up the .ino

Picture of Open Up the .ino

Download the Tiny9_LIS2HH12_and_RGB.ino file from Github here

After you down load the .ino, open it up in the Arduino IDE.

Step 5: The Code

You will notice in the code 1 line usually is made LOW. This is because we are using Arduino Pins D2, D3, D4 as current Sink versus Current drivers. Typically Pins on Processors can Provide more current in a Current Sink mode versus Current Drive mode.

Definition of Current Sink & Current Driver

Current Sink means that the Pin on a processor pulls to ground the power source that it is tied to.

Current Driver means that the Pin on a processor supplies the source with the Power.

if(x1 < -0.9){

digitalWrite(redledPin, LOW); //Turn on Red LED Pin if X’s gravity in the X direction is less than (<) -0.9g

digitalWrite(greenledPin, HIGH); //Turn off Green LED

digitalWrite(blueledPin, HIGH); //Turn off Blue LED

}

else if(y1 < 0.9){

digitalWrite(blueledPin, LOW); //Turn On Blue LED if Y’s Gravity in y direction is < 0.9

digitalWrite(greenledPin, HIGH); //Turn off Green LED

digitalWrite(redledPin, HIGH); //Turn off Red LED

}

else if(z1 < -0.9){ // if gravity in the Z direction is < -0.9g turn on Green LED

digitalWrite(greenledPin, LOW); //Turn on Green LED

digitalWrite(redledPin, HIGH); //Turn off Red LED

digitalWrite(blueledPin, HIGH); //Turn off Blue LED

}

else { //Turns off all LEDs

digitalWrite(greenledPin, HIGH);

digitalWrite(redledPin, HIGH);

digitalWrite(blueledPin, HIGH);

}