gobot.io/x/gobot/v2@v2.1.0/platforms/neurosky/README.md (about)

     1  # Neurosky
     2  
     3  NeuroSky delivers fully integrated, single chip EEG biosensors. NeuroSky enables its partners and developers to bring their brainwave application ideas to market with the shortest amount of time, and lowest end consumer price.
     4  
     5  This package contains the Gobot adaptor and driver for the [Neurosky Mindwave Mobile EEG](http://store.neurosky.com/products/mindwave-mobile).
     6  
     7  ## How to Install
     8  Installing Gobot with Neurosky support is pretty easy.
     9  
    10  ```
    11  go get -d -u gobot.io/x/gobot/v2/...
    12  ```
    13  
    14  ## How To Connect
    15  
    16  ### OSX
    17  
    18  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.
    19  
    20  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`
    21  
    22  ### Ubuntu
    23  
    24  Connecting to the Mindwave from Ubuntu or any other Linux-based OS can be done entirely from the command line using [Gort](https://gobot.io/x/gort) CLI commands. Here are the steps.
    25  
    26  Find the address of the Mindwave, by using:
    27  ```
    28  gort scan bluetooth
    29  ```
    30  
    31  Pair to Mindwave using this command (substituting the actual address of your Mindwave):
    32  ```
    33  gort bluetooth pair <address>
    34  ```
    35  
    36  Connect to the Mindwave using this command (substituting the actual address of your Mindwave):
    37  ```
    38  gort bluetooth connect <address>
    39  ```
    40  
    41  ### Windows
    42  
    43  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`.
    44  
    45  ## How to Use
    46  
    47  This small program lets you connect the Neurosky an load data.
    48  
    49  ```go
    50  package main
    51  
    52  import (
    53  	"fmt"
    54  
    55  	"gobot.io/x/gobot/v2"
    56  	"gobot.io/x/gobot/v2/platforms/neurosky"
    57  )
    58  
    59  func main() {
    60  	adaptor := neurosky.NewAdaptor("/dev/rfcomm0")
    61  	neuro := neurosky.NewDriver(adaptor)
    62  
    63  	work := func() {
    64  		neuro.On(neuro.Event("extended"), func(data interface{}) {
    65  			fmt.Println("Extended", data)
    66  		})
    67  		neuro.On(neuro.Event("signal"), func(data interface{}) {
    68  			fmt.Println("Signal", data)
    69  		})
    70  		neuro.On(neuro.Event("attention"), func(data interface{}) {
    71  			fmt.Println("Attention", data)
    72  		})
    73  		neuro.On(neuro.Event("meditation"), func(data interface{}) {
    74  			fmt.Println("Meditation", data)
    75  		})
    76  		neuro.On(neuro.Event("blink"), func(data interface{}) {
    77  			fmt.Println("Blink", data)
    78  		})
    79  		neuro.On(neuro.Event("wave"), func(data interface{}) {
    80  			fmt.Println("Wave", data)
    81  		})
    82  		neuro.On(neuro.Event("eeg"), func(data interface{}) {
    83  			eeg := data.(neurosky.EEGData)
    84  			fmt.Println("Delta", eeg.Delta)
    85  			fmt.Println("Theta", eeg.Theta)
    86  			fmt.Println("LoAlpha", eeg.LoAlpha)
    87  			fmt.Println("HiAlpha", eeg.HiAlpha)
    88  			fmt.Println("LoBeta", eeg.LoBeta)
    89  			fmt.Println("HiBeta", eeg.HiBeta)
    90  			fmt.Println("LoGamma", eeg.LoGamma)
    91  			fmt.Println("MidGamma", eeg.MidGamma)
    92  			fmt.Println("\n")
    93  		})
    94  	}
    95  
    96  	robot := gobot.NewRobot("brainBot",
    97  		[]gobot.Connection{adaptor},
    98  		[]gobot.Device{neuro},
    99  		work,
   100  	)
   101  
   102  	robot.Start()
   103  }
   104  ```