Introduction: Tinee9: RGB LED Module
Tinee9 is bringing you a couple of new surprises today:
1: The Tiny9 RGB Led Module
2: www.Tinee9.com just launched where you can buy Tinee9 products or other vendor products to help you get started with your prototyping.
*Tiny9 or Tinee9 are the same company just working out the kinks in the business name. Please PM me and let me know what lettering you like better out of Tiny9 or Tinee9.
*Please subscribe/follow my instructable feed.
*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
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.
Step 2: Materials
Materials you need for this instructable are:
You can find the items at this location- https://www.tinee9.com/collections/frontpage
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
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
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);
}
Step 6:
You may move the breadboard around while running the code to see the LEDs change colors in different positions.
Enjoy and come up with different projects with the Tiny9:RGB LED and Tiny9:Accelerometer.
Please let me know what you come up with.