hybridgroup.gobot/platforms/neurosky/README.md

103 lines
3.0 KiB
Markdown
Raw Normal View History

2014-07-07 03:17:10 +08:00
# Neurosky
2014-06-10 10:01:53 +08:00
This package contains the Gobot adaptor and driver for the [Neurosky Mindwave Mobile EEG](http://store.neurosky.com/products/mindwave-mobile).
## Installing
2014-06-10 10:01:53 +08:00
```
2014-07-07 03:17:10 +08:00
go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/gobot/platforms/neurosky
2014-06-10 10:01:53 +08:00
```
2014-06-10 10:01:53 +08:00
## How To Connect
2014-06-10 10:01:53 +08:00
### OSX
2014-06-10 10:01:53 +08:00
In order to allow Gobot running on your Mac to access the Mindwave, go to "Bluetooth > Open Bluetooth Preferences > Sharing Setup" and make sure that "Bluetooth Sharing" is checked.
2014-06-10 10:01:53 +08:00
Now you must pair with the Mindwave. Open System Preferences > Bluetooth. Now with the Bluetooth devices windows open, hold the On/Pair button on the Mindwave towards the On/Pair text until you see "Mindwave" pop up as available devices. Pair with that device. Once paired your Mindwave will be accessable through the serial device similarly named as `/dev/tty.MindWaveMobile-DevA`
2014-06-10 10:01:53 +08:00
### Ubuntu
2014-06-10 10:01:53 +08:00
Connecting to the Mindwave from Ubuntu or any other Linux-based OS can be done entirely from the command line using [Gort](https://github.com/hybridgroup/gort) CLI commands. Here are the steps.
2014-06-10 10:01:53 +08:00
Find the address of the Mindwave, by using:
```
gort scan bluetooth
```
2014-06-10 10:01:53 +08:00
Pair to Mindwave using this command (substituting the actual address of your Mindwave):
```
gort bluetooth pair <address>
```
2014-06-10 10:01:53 +08:00
Connect to the Mindwave using this command (substituting the actual address of your Mindwave):
```
gort bluetooth connect <address>
```
2014-06-10 10:01:53 +08:00
### Windows
2014-06-10 10:01:53 +08:00
You should be able to pair your Mindwave using your normal system tray applet for Bluetooth, and then connect to the COM port that is bound to the device, such as `COM3`.
2014-06-10 10:01:53 +08:00
## Examples
2014-06-10 10:01:53 +08:00
```go
2014-07-11 08:02:00 +08:00
2014-06-10 10:01:53 +08:00
import (
2014-07-11 08:02:00 +08:00
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/neurosky"
2014-06-10 10:01:53 +08:00
)
func main() {
2014-07-11 08:02:00 +08:00
gbot := gobot.NewGobot()
adaptor := neurosky.NewNeuroskyAdaptor("neurosky", "/dev/rfcomm0")
neuro := neurosky.NewNeuroskyDriver(adaptor, "neuro")
work := func() {
gobot.On(neuro.Event("extended"), func(data interface{}) {
fmt.Println("Extended", data)
})
gobot.On(neuro.Event("signal"), func(data interface{}) {
fmt.Println("Signal", data)
})
gobot.On(neuro.Event("attention"), func(data interface{}) {
fmt.Println("Attention", data)
})
gobot.On(neuro.Event("meditation"), func(data interface{}) {
fmt.Println("Meditation", data)
})
gobot.On(neuro.Event("blink"), func(data interface{}) {
fmt.Println("Blink", data)
})
gobot.On(neuro.Event("wave"), func(data interface{}) {
fmt.Println("Wave", data)
})
gobot.On(neuro.Event("eeg"), func(data interface{}) {
eeg := data.(neurosky.EEG)
fmt.Println("Delta", eeg.Delta)
fmt.Println("Theta", eeg.Theta)
fmt.Println("LoAlpha", eeg.LoAlpha)
fmt.Println("HiAlpha", eeg.HiAlpha)
fmt.Println("LoBeta", eeg.LoBeta)
fmt.Println("HiBeta", eeg.HiBeta)
fmt.Println("LoGamma", eeg.LoGamma)
fmt.Println("MidGamma", eeg.MidGamma)
fmt.Println("\n")
})
}
robot := gobot.NewRobot("brainBot",
[]gobot.Connection{adaptor},
[]gobot.Device{neuro},
work,
)
gbot.AddRobot(robot)
gbot.Start()
2014-06-10 10:01:53 +08:00
}
2014-07-11 08:02:00 +08:00
2014-06-10 10:01:53 +08:00
```