Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading my brainwaves in QB64
#1
Lightbulb 
I recently purchased a NeuroSky MindWave Mobile 2, an very affordable Bluetooth EEG headset ($129/€125/£107/₹11,065). Due to compatibility issues with Windows 11, I installed Windows 10 as a secondary operating system. After trying several apps, I discovered that the device transmits brainwave data to a virtual COM4 port, appearing as chunks of ASCII characters. By converting the ASCII characters to their numerical values, I can graphically represent the data, which reflects my brain activity. For instance, blinking my eyes or focusing on a photo's details results in noticeable data changes. It looks like there are also variable names included in the data, because between the variable data there are also values that don't change and show up as a dotted line.
These data variations can serve as inputs for applications like computer games or even maybe a type-with-your-brain interface (like a P300 speller, although I don't know yet if the device is capable of detecting P300 waves). I've also experimented with converting the brainwaves into sounds.
The MindWave comes with a developer kit and a library DLL (ThinkGear64.dll) that I aim to integrate into QB64. This integration would provide structured and accurate frequency data corresponding to different brainwave types (alpha, beta, etc.), enabling a broader range of applications.
Has anyone experience integrating such libraries into QB64? Any guidance on effectively utilizing ThinkGear64.dll within QB64 would be greatly appreciated.

Code: (Select All)
Screen _NewImage(2560, 1440, 256)
Dim dataByte As String * 1
Dim numericValue As Integer
Dim comPort As String
comPort = "COM6:57600,N,8,1,BIN"
On Error GoTo ErrorHandler
Open comPort For Binary As #1
Do
    If Loc(1) > 0 Then
        Get #1, , dataByte
        numericValue = Asc(dataByte)
        numericValue = numericValue
' (I exclude the variables that don't change, not a very elegant solution)
        If numericValue <> 0 And numericValue <> 2 And numericValue <> 1 And numericValue <> 4 And numericValue <> 83 And numericValue <> 255 And numericValue <> 254 And numericValue <> 254 And numericValue <> 42 And numericValue <> 128 And numericValue <> 41 And numericValue <> 170 And numericValue <> 85 And numericValue <> 40 And numericValue <> 34 And numericValue <> 91 And numericValue <> 82 And numericValue <> 43 And numericValue <> 84 Then teller = teller + 1
        If teller > 2558 Then teller = 0: oldteller = 0
        Line (teller + 1, 0)-(teller + 2, 1440), 0, BF
        If numericValue <> 0 And numericValue <> 2 And numericValue <> 1 And numericValue <> 4 And numericValue <> 83 And numericValue <> 255 And numericValue <> 254 And numericValue <> 254 And numericValue <> 42 And numericValue <> 128 And numericValue <> 41 And numericValue <> 170 And numericValue <> 85 And numericValue <> 40 And numericValue <> 34 And numericValue <> 91 And numericValue <> 82 And numericValue <> 43 And numericValue <> 84 Then Line (oldteller, oldNnumericValue + 400)-(teller, numericValue), 10
        Let oldNnumericValue = numericValue
        Let oldteller = teller
    End If
Loop Until InKey$ = Chr$(27)
Close #1
Print "Connection closed."
End
ErrorHandler:
Print "Dude, you did something wrong!"


[Image: image.png][Image: 71zo-F122og-L-AC-SL1500.jpg][Image: unnamed.png]
Reply
#2
This is super cool. Thanks for sharing. That input device could be cool for a horror game. Make things scarier as the person gets more nervous. Cabela's Dangerous Hunts did that once on the Wii. The gun controller had a heart sensor built into the pump and would have more animals jump out to kill you as you get more nervous.
The noticing will continue
Reply
#3
There's pretty sweet! I didn't know QB64 could access COM ports like QBasic could. I knew a guy back in the 90's that controlled robots with the COM port using QBasic, but I don't have any of the code, sorry to say. I'm reading that a Virtual Com Port runs through the USB, pretty cool!
Reply
#4
I hooked it up to my forehead today and got the following string result....

Print  String$(infinity, 196)

Pete Huh
Reply




Users browsing this thread: 2 Guest(s)