I found this cool tutorial to use a small arduino to connect an old NeXT keyboard to a computer via USB. It looked like a fun project and I have several of these keyboards around (and they’re great for typing on). I wondering if I needed to use the arduino board (which I don’t have) or if I could do the same thing with spark core (which I already have)
Looks like you’ll just need to drop those functions in and/or make a library! Data pin from the keyboard goes into one of the D# pins on the Spark and you’re off to the races.
Thanks for the quick reply. I guess the part I’m a little lost about (with the original instructions) is how the spark core or arduino pretend to be a USB keyboard/hid. It seems like these projects both output directly over serial. Does a computer automatically interpret these serial commands as USB HID commands?
Thanks so much for that link! And please pardon my ignorance. Does the original Arduino Project I linked to feature a similar Keyboard/HID system as what is being developed for Spark? The reason I ask is I don’t mind getting the Arduino. I still have other plans for the Spark Core. But if I could use the Spark Core for effectively the same the thing, why not.
Ah great! thanks for the clarification. Looks like I’ll stick with the Arduino on this one. Seems like a waste to use the spark core on a non-wifi connected device anyway
Thanks so much for your help. I’ll reply on this post when I get it done. (although I’m not sure how appropriate it is to post Arduino progress here
When you say [quote=“BDub, post:6, topic:3895”]
Sounds like you might be the first one doing something with the Keyboard HID so let us know how it goes
[/quote]
does this mean I have missed something ? Is there a branch where I could get my hands dirty?
At the mo I’m still “wasting” my time on my Android ExtTinkerApp, but if the HID USB is about to descend from the on us, I’d be right into that instead !
Thanks @BDub,
I knew that Satish was on it - therefore didn’t actually go into the link and completely missed the pull request and that it is incorporated now.
To enable HID support in case someone likes to test this feature locally:
Edit main.h file, uncomment only one define out of the three from below and run the make command:
//#define SPARK_USB_SERIAL
//#define SPARK_USB_MOUSE
//#define SPARK_USB_KEYBOARD
Both “spark_wiring_usbmouse.h” & “spark_wiring_usbkeyboard.h” has already been added to application.h so no need to add them in your application code.
Please note: Currently only one USB feature will work at a time.
If none is selected, USB Serial is enabled by default.
Also to add on to my earlier message both the Mouse and Keyboard are USB HID class based implementation so the Host PC should automatically recognize the Spark Core as a physical Mouse or Keyboard with Mouse.begin() or Keyboard.begin() in application code respectively i.e. no need to install a separate driver whereas the USB Serial is based on CDC class for which a virtual com port driver is needed on windows based host PC.
When you say[quote=“satishgn, post:11, topic:3895”] Currently only one USB feature will work at a time.
[/quote]
I hope once each individual feature has been confirmed stable, there will be the option for composite devices as Arduino/Teensyduino provide - Mouse/Keyboard or Mouse/Keyboard + Serial. And in the long run even some of these
Correct @ScruffR, once each individual HID feature Mouse and Keyboard are tested and deemed stable enough, we think a composite devices scheme that you mentioned above should be easily doable. As of now only the USB Serial is stable and which is performing well on the field.
I’ve been trying this out but have been unable to get the keyboard stuff to work. I’ve compiled the firmware with the following application:
void setup()
{
//Setup the Tinker application here
//Register all the Tinker functions
Spark.function("keyprint", keyprint);
Keyboard.begin();
pinMode(D7, OUTPUT);
}
/* This function loops forever --------------------------------------------*/
void loop()
{
//This will run in a loop
Keyboard.write('A');
digitalWrite(D7, HIGH);
delay(500);
digitalWrite(D7, LOW);
delay(100);
}
int keyprint(String what)
{
Keyboard.print(what);
return 1;
}
The flash went ok, the D7 led is blinking and I see a new HID device on the computer (at least on windows), but no keypresses. Not from the loop, and not through the function. I’ve tried it on mac and windows.