Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

Controlling Led brightness using Meditation and attention level (Part 5/13)

By Arpit jain

Controlling Led brightness using Meditation and attention level

SUMMARY
After talking about the theoretical concept of brain waves, it’s time to check out some real-time applications.  Here, we are going to discuss the efficiency, flexibility and various features of what we have done till now. Presently, I am thinking of changing something depending on my attention and meditation level, say the brightness of a small LED. We will be controlling the brightness of an LED using the attention and meditation levels of our Brain at any particular time. We will be using Arduino UNO and mindflex sensor which we have chosen to read the brain wave and an LED to show the results.
DESCRIPTION
We are changing the brightness of the LED which can be easily controlled using PWM technique.
Quick Note: PWM is a technique to control analog devices by digital outputs. By digital outputs, we are creating a square wave of ON and OFF patterns. This ON and OFF pattern is used to create analog voltage ranging between Low Voltage and High Voltage and we can vary the voltage by changing the duration of ON time with respect to OFF time.
If we pass this ON OFF pattern to the LED at high speed, apparently an analog voltage is received and its brightness changes accordingly.
First, let us control the LED brightness using the attention level.
So, now to control an LED’s brightness, we will measure the attention level from e meters of the TGAM1 chip. Please note that this chip gives us the attention level on a scale of 0 – 100. It is also interesting to know that the chip transmits the Meditation signals only when the sensor is accurately connected to the Brain and the sensor module is getting 100% signal strength. The signal strength ranges from 0 – 200. 
Image Showing Brightness of an LED Being Controlled by Meditation Level Using Brainwave Sensor
Fig. 1: Image Showing Brightness of an LED Being Controlled by Meditation Level Using Brainwave Sensor 
Dramatically, when the signal strength is 100% then the sensor sends 0 value and when the sensor sends 200 this means there is no connection of the metal sensor to our brain. So, after confirming that our signal strength is 100% and our sensor is sending 0 serially for signal strength we can perform this experiment.
Now as we know that the PWM has a duty cycle which determines the analog level. The duty cycle is basically the on time divided by total time period. To change the brightness of the LED on the basis of attention level, we will change the duty cycle of PWM.
As we are getting the meditation value from the sensor on a scale of 0 -100, we will make the value of duty cycle equals to meditation value subtracted from 100. For example, if the meditation value from the sensor is 40 then the duty cycle is 100–40=60.
Image Showing Brightness of an LED Being Controlled by Meditation Level Using Brainwave Sensor
Fig. 2: Image showing brightness of an LED being controlled by Meditation Level using Brainwave Sensor 
This will make the LED brightness parallel to the meditation level. You can check the code and the video for this experiment. After the meditation level, we will do the same with the attention level. Just to remind again, please check that the signal strength is coming 100% and with 0 value. 
Image Showing Brightness of an LED Being Controlled by Meditation Level Using Brainwave Sensor
Fig. 3: Image showing brightness of an LED being controlled by Meditation Level using Brainwave Sensor 
We again need to take the attention values from the sensor and change the PWM duty cycle with respect to the attention values. Again, make the value of duty cycle equals to the attention value subtracted from 100. For ex, if the meditation value from the sensor is 40 than the duty cycle is 100 – 40 = 60.
Check out the software section to see how PWM is implemented in the code.
And we are also done with the brightness control using attention values. Check out the code and video to perform the experiment yourself.
Block Diagram of MindFlex Brainwave Sensor based LED Brightness Controller
Fig. 4: Block Diagram of MindFlex Brainwave Sensor based LED Brightness Controller

Hardware: Please find the attached circuit diagram of the connections we need to do. 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.

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 ex
AnalogWrite(13,240);
AnalogWrite in arduino is used 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.
Now 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.
So it will be analogWrite (pin,evalue*2.55) in a loop.
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. In the upcoming articles, I will explain how we can control various objects without signal attention and meditation values.
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 will create noise in the sensor values.
Try this experiment and let me know if you have any problem. Stay tuned for more experiments based on Brain Waves related to controlling a motor. 

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

Circuit-Diagram-MindFlex-Brainwave-Sensor-LED-Brightness-Controller

Project Video


Filed Under: Electronic Projects

 

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • PS2 Keyboard To Store Text In SD Card Using Arduino Circuit Setup On Breadboard
    How To Use PS2 Keyboard To Store Text In SD Card Using Arduino- (Part 42/49)
  • Wireless Path Tracking System Using Mouse, XBee And Arduino Circuit Setup On Breadboard
    How To Make A Wireless Path Tracking System Using Mouse, XBee And Arduino- (Part 43/49)
  • How to Make a Wireless Keyboard Using Xbee with Arduino- (Part 44/49)
  • Making Phone Call From GSM Module Using Arduino Circuit Setup On Breadboard
    How to Make Phonecall From GSM Module Using Arduino- (Part 45/49)
  • How to Make a Call using Keyboard, GSM Module and Arduino
    How To Make A Call Using Keyboard, GSM Module And Arduino- (Part 46/49)
  • Receiving SMS Using GSM Module With Arduino Prototype
    How to Receive SMS Using GSM Module with Arduino- (Part 47/49)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • What is a low power design?
  • Renesas partners with Tata to accelerate progress in advanced electronics
  • STMicroelectronics’ new touchscreen controller for smartphones enables longer runtime
  • Samsung unveils ISOCELL image sensor with industry’s smallest 0.56μm pixel
  • Renesas and Cyberon to deliver integrated voice-user interface solutions

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Code Optimization
  • How to define decrement variables in HFSS opt?
  • simple LSB explanation please
  • Difference between pierce and colpitts
  • Natural Convection Heatsink for 80W power dissipation?

RSS Electro-Tech-Online.com Discussions

  • Review of electric circuit with Arduino
  • intro to PI
  • Lighting a .010 green fiber optic with led
  • Bridge purpose in connecting the two functional circuit
  • ICM7555 IC duty cycle limit at high frequency?
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering