LinkIt ONE Tutorial - Colorful World


What We’re Doing
We now know how to control the LED’s lets combine it with basic idea about combining colors. The R-Red G-Green B-Blue are the primary colors these colors when mixed in different proportion gives different colors. An RGB LED consists of four pins the long lead is the positive terminal and the other three lead are for controlling RGB colors. Make connections as shown in the Fig5.2 and upload the code.
Things you need
  • LinkIt One x 1
  • Break board x 1
  • Resistors 330Ω,10kΩ,1kΩ x 3
  • 8mm RGB LED x 1
  • Transistor(2N3904) x 3
  • Button x 3
Please click on the button below to download the code for the kit:
You can unzip the file to the Examples folder of your Arduino IDE.
To access the demo code open:
File -> Examples -> Starter Kit for LinkIt -> Basic -> L5_Color_Pannel
const int ledR = 2; const int ledB = 3; const int ledG = 4; const int buttonR = 5; const int buttonG = 6; const int buttonB = 7; void setup() { pinMode(ledR, OUTPUT); // set all led pin OUTPUT pinMode(ledG, OUTPUT); pinMode(ledB, OUTPUT); pinMode(buttonR, INPUT); // set all button pin INPUT pinMode(buttonG, INPUT); pinMode(buttonB, INPUT); } void loop() { int stateR = 1-digitalRead(buttonR); // get state of button int stateG = 1-digitalRead(buttonG); int stateB = 1-digitalRead(buttonB); digitalWrite(ledR, stateR); // set led digitalWrite(ledG, stateG); digitalWrite(ledB, stateB); delay(10); }
  • Wrong color display
    • Since there are four pins in the LED, there exists probability of error in the connection make sure that all the control pins are connected to the correct leads
  • Reddish appearance?
    • In RGB LED, red color has high intensity than the other two colors for a given voltage. In order to make the colour overall tone in harmony, try to reduce the intensity of RED LED with a larger resistance value.
Making it better
Do you want to get more colors? There are two buttons to adjust the RGB values of successive rises. Then we can find more colors. Try to build the circuit linking the two analog output interface (RGB values were increased higher or lower). Code has been defined to get it. (PWM analog output, you get a return value of the output of the analog 0-1023 to use.)
To open the demo code:
File -> Examples -> Starter Kit for LinkIt -> Extend_Lesson –> L5_Colourful_RGB
More ideas
How expand the code to turn down the RGB values?

Help us make it better

Thank you for choosing Seeed. A couple of months ago we initiated a project to improve our documentation system. What you are looking at now is the first edition of the new documentation system. Comparing to the old one, here is the progresses that we made:
  • Replaced the old documentation system with a new one that was developed from Mkdocs, a more widely used and cooler tool to develop documentation system.
  • Integrated the documentation system with our official website, now you can go to Bazaar and other section like Forum and Community more conveniently.
  • Reviewed and rewrote documents for hundreds of products for the system’s first edition, and will continue migrate documents from old wiki to the new one.
An easy-to-use instruction is as important as the product itself. We are expecting this new system will improve your experience when using Seeed’s products. However since this is the first edition, there are still many things need to improve, if you have any suggestions or findings, you are most welcome to submit the amended version as our contributor or give us suggestions in the survey below, Please don’t forget to leave your email address so that we can reply.
Happy hacking