Changing the Color of RGB LED
SUMMARY
In this series we have conducted various experiments, out of which the previous one was related to dancing LEDs. Now let’s do some more experiments and see how far we can extend the Brain wave.
Earlier we have changed the LED brightness using the Attention and Meditation values. The results were good and we were able to see the variation in the form of brightness. Though we didn’t get much clear variation, we also performed a similar experiment using motor and changed the motor speed. Now let us try one more such experiment and this time we will change the colour of the RGB Led. Also, earlier we have used attention/meditation waves of e meters; this time we will use some of the Brain Waves to control the colour.

Fig. 1: Image showing RGB LED Color Change by Brainwave
DESCRIPTION
RGB LEDs are colourful LEDs which can change the colour depending on the input. These LEDs are also controlled by the PWM wave. Many of things which work on variations can be controlled by PWM. So, in this article we will apply an RGB LED in front of the pin while changing the values.

Fig. 2: Image showing RGB LED Color Change by Brainwave

Fig. 3: Image showing RGB LED Color Change by Brainwave

Fig. 4: Image showing RGB LED Color Change by Brainwave
We will take the signals from the Mindflex Sensor and then extract the values of the desired signal. Once we have got the value we will map the value with that of 0 to 255. We have earlier seen the calculations of PWM before also.

Fig. 5: Block Diagram of Brain Wave Module based RGB Color Changer
Hardware: Please find the attached circuit diagram of the connections that need to be established. We have taken a pin from T pin of the mindflex sensor and connected that pin to the Rx pin of our Arduino UNO. Also, we have shorted the ground of both the Sensor and UNO by a wire. Please take special care while soldering anything to the Mindflex sensor as pins are very close to each other. After that an LED is connected to PIN 9, by which we the PWM signals are sent.
Softwares: Let us come to the software part. We have been receiving the E meter values from the sensor to our arduino via T pin. Once we have received the value at any particular point, we just need to convert that value level to the brightness of LED. As discussed previously, we will use PWM techniques. PWM in arduino is done by analogWrite.
For example:
AnalogWrite(13,240);
AnalogWrite in arduino is use to write PWM wave to a pin. In above example, first parameter is PIN Number and second is PIN value. So, we are writing 240 to pin 13. Now we can calculate the analog voltage at the value 240 easily. Total voltage range is 0v – 5v and value range is 0- 255.
This means 240 = (5/255)*240 = ~4.70V.
The values we get from e meters are in range 0 – 100.
So let’s say we get evalue = 70.
We will multiply the e value by 2.55 to make it in the range of 0-255.
It will be analogWrite(pin,evalue*2.55) in a loop.
Now the values we are getting are in range of 0 to 999999, so we will map the values in the range of 0 to 255 to produce above results , by using the map function of arduino .
output = map(num,0,999999,0,180);
Few points to Note:
The sensor usually gives the strength from 60 – 80% due to its orientation and the spot where we place it. Try to keep the metal sensor exactly above your left eye. I have also applied salt water at my forehead for better connectivity to the sensor. If you do not find it 100%, then it is normal.
The signal strength also disrupts about how we solder the wire to the T pin. Try to shield this wire and also make sure that the references probes are correctly connected. If you have any wire connected to the EEG pin of the sensor, please disconnect that wire as that might create a lot of noise in the sensor values.
You can also try this experiment on your own and let us know about your valuable feedback. Stay tuned for our forthcoming experiment on controlling servo motor through brain waves.
Project Source Code
###
//Program to#include// Set up the brain parser, pass it the hardware serial object you want to listen on.Brain brain(Serial);//char a[400];String a,a1;int v = 0;int z=0,output;uint32_t num=0;uint32_t num1=0;void setup() {// Start the hardware serial.Serial.begin(9600);pinMode(9, OUTPUT);}void loop() {// Expect packets about once per second.// The .readCSV() function returns a string (well, char*) listing the most recent brain data, in the following format:// "signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma"if (brain.update()) {// Serial.println(brain.readErrors());// Serial.println(brain.readCSV());//sprintf(a, "%c",brain.readCSV());a = brain.readCSV();v = a.indexOf(',');v = a.indexOf(',',v+1);v = a.indexOf(',',v+1);v = a.indexOf(',',v+1);z = a.indexOf(',',v+1);a1 = a.substring(v+1,z);num = a1.toInt();v = a.indexOf(',',z+1);a = a.substring(z+1,v);num1 = a.toInt();//Serial.println(num);Serial.println(num1);analogWrite(9,output)//brain.readCSV().toCharArray(a,200);}}###
Circuit Diagrams
Filed Under: Brainwave, Electronic Projects, Tech Articles, Tutorials
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.