Hello,
I'm trying to create a project involving arduino communication. I've managed to acomplish a few things, but there are still some issues I need help with.
What I have is a Form with 0-9 + enter keyboard(Object - keyboard0) and string(Object - strings9). What I'd like to achieve is to be able to input a number from keyboard object to string object and write it to arduino with "enter" key. I have seen a few tutorials, example files etc. but can't get it to work. I definetely have the communication/wiring setup correctly, since I am already reading a few variables from arduino and it works like a charm.
As far as I understand, I need to update my code to invole the following:
In arduino setup function:
In arduino loop function:
And the Eventhandler:
The code tries just to get any data to show on string9 object after pressing keyboard, I'm aware it is not doing exactly what I've described at the beginning.
I added a simple diode to output 8 to be able to monitor if the handler function is ever called, it is not no matter how hard I mash the keyboard. Now I've seen every tutorial mentions adding the keyboard to "Events" within Workshop software, so right now I have my keyboard0 event set to "OnChanged: Report Message". But every single example file I downloaded doesn't have it set up, so I'm kind of confused. I did manage to get the read ONCE, no idea how, but pressing 0 resulted in 48 written to string9. But after that, no success.
I'm trying to create a project involving arduino communication. I've managed to acomplish a few things, but there are still some issues I need help with.
What I have is a Form with 0-9 + enter keyboard(Object - keyboard0) and string(Object - strings9). What I'd like to achieve is to be able to input a number from keyboard object to string object and write it to arduino with "enter" key. I have seen a few tutorials, example files etc. but can't get it to work. I definetely have the communication/wiring setup correctly, since I am already reading a few variables from arduino and it works like a charm.
As far as I understand, I need to update my code to invole the following:
In arduino setup function:
Code:
Serial.begin(9600); genie.Begin(Serial); genie.AttachEventHandler(myGenieEventHandler); pinMode(RESETLINE, OUTPUT); pinMode(8, OUTPUT); digitalWrite(RESETLINE, 0); // Reset delay(100); digitalWrite(RESETLINE, 1); // unReset delay (5000);
Code:
genie.DoEvents();
Code:
void myGenieEventHandler (void) { int keyboardValue; digitalWrite(8, HIGH); genieFrame Event; genie.DequeueEvent(&Event); // Remove this event from the queue if (Event.reportObject.object == GENIE_OBJ_KEYBOARD) // If this event is from a Keyboard { if (Event.reportObject.index == 0) // If from Keyboard0 { keyboardValue = genie.GetEventData(&Event); // Get data from Keyboard0 genie.WriteStr(9, keyboardValue); } } }
I added a simple diode to output 8 to be able to monitor if the handler function is ever called, it is not no matter how hard I mash the keyboard. Now I've seen every tutorial mentions adding the keyboard to "Events" within Workshop software, so right now I have my keyboard0 event set to "OnChanged: Report Message". But every single example file I downloaded doesn't have it set up, so I'm kind of confused. I did manage to get the read ONCE, no idea how, but pressing 0 resulted in 48 written to string9. But after that, no success.

Comment