Raspberry Pi GPIO LED Lighting with the Neurosky Mindwave and Mindwave Mobile Electroencephalography (Brainwave, EEG) Sensor
nled
Raspberry Pi GPIO LED Lighting with Neurosky Mindwave and Mindwave Mobile
How to download and execute:
(sudo) pip install nled
(sudo) python -m nled
(You need root permission because of rfcomm)
You need to connect Red LED(s) to GPIO 23, Yellow LED(s) to GPIO 24, Green LED(s) to GPIO 18
Other than this, you don't need any knowledge of Linux or python, etc to execute this.
MAKE SURE YOU ONLY USE Ctrl+c TO TURN OFF THE PROGRAM
ELSE GPIO MAY WORK WITHOUT NOTICE UNTIL REBOOT
There will be a warning about GPIOs later on if you use anything other than Ctrl+c
It may be good to use sudo pkill -f python(Optional, all python scripts will terminate)
If you are using NeuroSky MindWave with RF Connector, there may be a warning or traceback about bluetooth not existing.
Just don't look at it. It isn't a problem and it will work as usual.
(Yet, I didn't use it, so if there's any other problems, feel free to make an issue on github)
And there will be an exception few seconds after start if you don't connect/turn on the headset.
For both cases, do Ctrl+c to turn off the program (and turn on the headset if you have the latter problem) and just execute the program again.
For NeuroPy library(improved speed with buffers, it comes with the package)
NeuroPy library written in python to connect, interact and get data from Neurosky's MindWave EEG headset.
This library is based on the mindwave mindset communication protocol published by Neurosky and is tested
with Neurosky Mindwave EEG headset.
More about the difference between the models of MindWave can be found HERE.
Usage
Importing the module:
from nled import NeuroPy
Initialising:
object1=NeuroPy("COM6",57600)
#windows
object1=NeuroPy("/dev/rfcomm0",57600)
#linuxAfter initialising , if required the callbacks must be set
then using the start method the library will start fetching data from mindwave
i.e.object1.start()
similarly stop method can be called to stop fetching the data
i.e.object1.stop()
The data from the device can be obtained using either of the following methods or bot of them together:
Obtaining value:
variable1=object1.attention
#to get value of attention# other variables: attention,meditation,rawValue,delta,theta,lowAlpha,highAlpha,lowBeta,highBeta,lowGamma,midGamma, poorSignal and blinkStrength
Setting callback:a call back can be associated with all the above variables so that a function is called when the variable is updated. Syntax:
setCallBack("variable",callback_function)
for eg. to set a callback for attention data the syntax will besetCallBack("attention",callback_function)
# other variables: attention,meditation,rawValue,delta,theta,lowAlpha,highAlpha,lowBeta,highBeta,lowGamma,midGamma, poorSignal and blinkStrength
Sample Program
from nled import NeuroPy
object1=NeuroPy("COM6") #If port not given 57600 is automatically assumed
#object1=NeuroPy("/dev/rfcomm0") for linux
def attention_callback(attention_value):
"this function will be called everytime NeuroPy has a new value for attention"
print "Value of attention is",attention_value
#do other stuff based on the obtained value of attention_value
#do some more stuff
return None
#set call back:
object1.setCallBack("attention",attention_callback)
#call start method
object1.start()
while True:
if(object1.meditation>70): #another way of accessing data provided by headset (1st being call backs)
object1.stop() #if meditation level reaches above 70, stop fetching data from the headset
More Information
Posted on Utopian.io - Rewarding Open Source Contributors
Your contribution cannot be approved because it does not follow the Utopian Rules.
You can contact us on Discord.
[utopian-moderator]
Hey @deveerei, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
@ehf, Upvote is the only thing I can support you.
This post has received a 0.35 % upvote from @drotto thanks to: @banjo.
Hello, you received a boost courtesy of @steemdunk! Steem Dunk is an automated curation platform that is easy and free for use by everyone. Need an instant boost? Send 0.200 SBD with your full post url as the memo to @steemdunk for an upvote. Join us at https://steemdunk.xyz
Upvote this comment to support the bot and increase your future rewards!
Congratulations! This post has been upvoted from the communal account, @minnowsupport, by ehf from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.
If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.