Old NeXT Keyboard to USB

Hey everyone,

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)

Let me know if you think it’s possible.

https://learn.adafruit.com/usb-next-keyboard-with-arduino-micro?view=all

-Jeff

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.

Edit: library exists at https://github.com/adafruit/USB-NeXT-Keyboard

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?

No, but the Spark team is working on adding Keyboard and Mouse HID compatibility :smile:

It looks like @satishgn has started the support for this:

But I’m not sure if it is considered working yet.

1 Like

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.

Thanks again!

Yes it does implement a Keyboard HID, look here:

Sounds like you might be the first one doing something with the Keyboard HID so let us know how it goes :wink:

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 :stuck_out_tongue:

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 :wink:

-Jeff

@BDub as the USB HID feature was one of the first things I wanted to see on the :spark: Core, I’m eagerly waiting for its arrival.

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 :blush: ? 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 :spark: :stars: on us, I’d be right into that instead :open_mouth:!

Yeah check my first reply... there is something in the works.

Thanks @BDub,
I knew that Satish was on it - therefore didn’t actually go into the link :blush: and completely missed :disappointed_relieved: the pull request and that it is incorporated now.

@Jeffburg, @BDub, @ScruffR, @emc2,

Time to get the HID stuff tested :smiley: We didn’t comment on HID work done so far since we are still waiting on new USB product IDs to be issued for both Keyboard and Mouse. Currently we have some random product IDs assigned just for testing but that’s going to change before merging this branch: https://github.com/spark/core-firmware/tree/feature/usb-hid-support with the master. The pull request is over here: https://github.com/spark/core-firmware/pull/162

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.

Happy Testing :smile:

2 Likes

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.

1 Like

I seriously need to setup my machine with local compiling and have more fun… :smiley:

Great to hear and I’ll be right at it ASAP.

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 :wink:

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.

1 Like

Hi,

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.

Any ideas?

I’ve just tried the mouse part, and that does seem to work ok.

Hi @clarity, I will try your sample code and let you know how it goes at my end by tomorrow.

Hi @clarity, it seems a small delay of 100 ms is required between key press and release.
I pushed a small commit to fix the missing keyboard write issue: https://github.com/spark/core-firmware/commit/cfa171edb52bee3a0d5ba67109af512829d490b6
Hope this solves your problem.

Hi @satishgn, yes, this works great! Thank you very much!

I have a few more questions:

  • is there a chance of having mouse&keyboard work at the same time, or is this a hardware limitation?
  • any idea on when this will be available on the main branch and through webide?