Control a Brain Powered Mood Lamp!

Three different colors were cool in the last project, but what about creating any color we want with our brain? Let’s build a project to make any color we want!

Before you need to ask, yes the subject of the video above needed about 20 seconds in the beginning to get focused!

Estimated Time 

Approximately One Hour

Number of People

1- 2 students per materials set

Necessary Supplies

  • One NeuroMaker BCI Unit
  • One Uno Board
  • USB cable 
  • Computer
  • At least four Male to Male Jumper Wires
  • Three current limiting resistors (This above video uses 250 Ohm resistors)
  • One RGB LED
  • One Breadboard
  • One ping pong ball with a hole cut in the bottom (optional)

Necessary Program Files

Please see the code below

Pre Check Items

  • NeuroMaker BCI Unit is fully charged
  • NeuroMaker BCI Connect Software is running properly


In the last lesson, we learned how to control three different LED lights with our attention score. Using this same knowledge, we are going to go one step further! There are special LED lights called RGB LEDs, which stand for red, green and blue. You can find these small LEDs nearly everywhere; in computer screens, TV’s, cell phones and more. These allow us to control different amounts of red, blue and green to mix any color we can think of!

Using NeuroMaker BCI, we are going to program different colors onto these special LEDs while using our attention score to trigger the color we want. Do you want to have our light turn red when we get super focused? How about orange when we start to drift our attention away? What about a beautiful royal purple when we hit a score we like? We can do all that and much, much more!

Table of Contents

Project Instructions

Just like our last project, we are going to need to build a simple circuit to get this off the ground. Although this LED gives us only one color, we can think of this light as three different lights combined into one. Therefore, our circuit will be arranged like we are controlling three different LEDs like the last one. We will need to connect each leg of the RGB LED to a digital pin along with a resistor. Finally, we will also need to connect the ground pin of this LED to ground. Let’s get going!

  • First and foremost, please check which kind of RGB LED you are using. There are two kinds: common cathode and common anode. Common cathode RGB LEDs share one leg of the LED to connect to ground, while common anode RGB LEDs share one leg to connect to power. In this example we will use a common cathode RGB LED. 
  • Connect digital pin 8 to a resistor and then to the red leg of the RGB LED.
  • Connect digital pin 9 to a resistor and then to the green leg of the RGB LED.
  • Connect digital pin 10 to a resistor and then to the blue leg of the RGB LED.
  • Finally, we need to connect our RGB LED ground leg to the ground pin on the UNO board.

To the right of this text, you can see a simple circuit diagram of the project we need to create.

The same advice from the last project applies here. If you are using an UNO board, please make sure you include resistors so that you don’t burn out the light on your LED!

If you wish to create an “orb” shown in the video at the top of the screen you can cut a hole in the bottom of a ping pong ball and place it on top of your RGB LED.

Now for our code. In our last LED project, each light could either be turned on or turned off with our digital.write function. Within this project we are going to use the analog.write function. Instead of only having two options of HIGH (on) or LOW (off), we can now choose any option in between. We can turn a light 20% on, 25% on, 68% on or any other state we want! 

The analog.write function in the Arduino IDE does this by taking different integer values from 0 to 255, giving us a total of 256 options (remember that 0 is one of the options!). Writing analog.write(0) will turn our light completely off and writing analog.write(255) will turn our light completely on. What is the number in the middle of 0 and 255 to turn our light halfway on? You guessed it, that would be 128! Writing analog.write(128) will turn our light halfway on.

This is a very powerful concept. Now we have the power to control how much red, blue and green in our light that we want. Do you want your light to be 50% red, 20% blue and 80% green? You could do that with the following analog.write functions:

  • analog.Write(redlight, 128); 
  • analog.Write(bluelight, 51)
  • analog.Write(greenlight, 205)

Now for the fun part. What if we could have a chart that could give us the combination of red, green and blue for any color we want? We can find this in an RGB color chart like this one: Let’s look at few of the examples they provide below. The right hand column of the chart below will give us the color combinations for each analog.write function we write into our code!

By using this new concept, let’s build 10 different colors that will work with ten different ranges of our attention values. We will create a different color for attention ranges of 0-9, 10-19, 20-29, etc. Run the code below and try to reach whatever color you wish to create with your brain.

The Code


Here are the combinations of red, green and blue we will use in this project:
red 255, 255, 255
purple 183, 77, 199
royalPurple 121, 66, 203
blue 66, 93, 203
acqua 66, 162, 203
acquamarine 66, 203, 194
brightGreen 7, 249, 104
solidGreen 0, 255, 0
yellow 249, 249, 7
orange 249, 128, 7


int redPin = 8;
int greenPin = 9;
int bluePin = 10;
char attentionScore;

void setup() {
  // put your setup code here, to run once:
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);

void setRGB(int red, int green, int blue)
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);

void loop() {

while (Serial.available()>0){
  attentionScore =;

if (attentionScore >= 0 && attentionScore < 10){
  setRGB(255, 255, 255);
if (attentionScore >= 10 && attentionScore < 20){
  setRGB(183, 77, 199);
if (attentionScore >= 20 && attentionScore < 30){
  setRGB(121, 66, 203);
if (attentionScore >= 30 && attentionScore < 40){
  setRGB(66, 93, 203);
if (attentionScore >= 40 && attentionScore < 50){
  setRGB(66, 162, 203);
if (attentionScore >= 50 && attentionScore < 60){
  setRGB(66, 203, 194);
if (attentionScore >= 60 && attentionScore < 70){
  //bright green
  setRGB(7, 249, 104);
if (attentionScore >= 70 && attentionScore < 80){
  //solid green
  setRGB(0, 255, 0);
if (attentionScore >= 80 && attentionScore < 90){
  setRGB(249, 249, 7);
if (attentionScore >= 90 && attentionScore <= 100){
  setRGB(249, 128, 7);

If you can successfully run this project, what else could you create with this knowledge? Could you create other colors? What about other attention ranges we can use?