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);



  • 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

Welcome to the new documentation system of Seeed Studio. We have made a lot of progress comparing to the old wiki system and will continue to improve it to make it more user friendly and helpful. The improvement can't be done without your kindly feedback. If you have any suggestions or findings, you are most welcome to submit the amended version as our contributor via Github or give us suggestions in the survey below, it would be more appreciated if you could leave your email so that we can reply to you. Happy Hacking!