Purpose (started 30 years ago!) was to design a device that would allow people with amputations, arthritis,etc. to use EMG as an input for a virtual keyboard.
Just over a year ago I learned about arduino and then discovered the teensy.
First step was to use a teensy++2 along with 5 buttons to generate the alphabet plus a few simple commands to be able to type a document. Pressing button #1 would type "a", pressing button #2 would type "b", pressing both would type "c", etc. With the help of several very generous and smart people I was able to make this work.
The next step was to find an affordable EMG sensor board and I found one at Advancertechnologies.
Now I am struggling to write a simple sketch to replace the digital buttons with the analog EMG sensors. To make things simple I am using 5 variable resistors to simulate the EMG sensors. I wrote a quick sketch to verify that this worked the same as the sensors.
Now to the struggle. I have no programing knowledge. Below is the start of a new sketch that I am trying to write. As you will quickly see I really need some help.
At this point:
char to_send = keymap[byte];
I am getting this error:
sketch_mar14anewkeyboardrevtidy1.ino: In function 'void loop()':
sketch_mar14anewkeyboardrevtidy1:44: error: expected primary-expression before ']' token
At the moment I am using serial print just to keep things simple.
Any help would be most appreciated.
Thank you,
Paul
Just over a year ago I learned about arduino and then discovered the teensy.
First step was to use a teensy++2 along with 5 buttons to generate the alphabet plus a few simple commands to be able to type a document. Pressing button #1 would type "a", pressing button #2 would type "b", pressing both would type "c", etc. With the help of several very generous and smart people I was able to make this work.
The next step was to find an affordable EMG sensor board and I found one at Advancertechnologies.
Now I am struggling to write a simple sketch to replace the digital buttons with the analog EMG sensors. To make things simple I am using 5 variable resistors to simulate the EMG sensors. I wrote a quick sketch to verify that this worked the same as the sensors.
Now to the struggle. I have no programing knowledge. Below is the start of a new sketch that I am trying to write. As you will quickly see I really need some help.
At this point:
char to_send = keymap[byte];
I am getting this error:
sketch_mar14anewkeyboardrevtidy1.ino: In function 'void loop()':
sketch_mar14anewkeyboardrevtidy1:44: error: expected primary-expression before ']' token
At the moment I am using serial print just to keep things simple.
Any help would be most appreciated.
Thank you,
Paul
Code:
int keymap[32] = {-1,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,40,42,44,57,0};
int sv0, sv1, sv2, sv3, sv4;
byte key;
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
key = 0;
sv0 = analogRead(A0);
sv1 = analogRead(A1);
sv2 = analogRead(A2);
sv3 = analogRead(A3);
sv4 = analogRead(A4);
if (sv0 > 250)
{
key = key | B00000001;
}
if (sv1 > 250);
{
key = key | B00000010;
}
if (sv2 > 250);
{
key = key | B00000100;
}
if (sv3 > 250);
{
key = key | B00001000;
}
if (sv4 > 250);
{
key = key | B00010000;
}
{
char to_send = keymap[byte];
Serial.print(to_send);
}
}