Keyboard for an Arduino?

I want to build a “PC” with an Arduino due, which doesn’t have a display, but writes everything on a blackboard.

Now, I obviously need a keyboard of some sort. As I’m using the arduino due I can use the keyboard library, so I can actually use a real keyboard, which has a lot more style than soldering my own. But how do you connect a Keyboard to the DUE? Maybe with an adapter like this one?

Also I’m having trouble understanding the USBhost library. Can somebody explain the functions “keyboard.getKey()” and “usb.task()” to me? If i have understood it correctly “keyboard.getKey()” simply returns the key pressed at the moment. But why, if that is all you need, do all the examples use “usb.task()” in the loop :o ?

What I basically need is just a way to create a string of characters using the keyboard as an Input.

Thanks :slight_smile:

#include <KeyboardController.h>

// Initialize USB Controller
USBHost usb;

// Attach Keyboard controller to USB
KeyboardController keyboard(usb);

void setup(){
  Serial.begin(9600);
}

void loop(){
  usb.Task();
}

void keyPressed() {
  Serial.print("Pressed:  ");
  Serial.print(keyboard.getKey());
  Serial.println();
}

Sorry, I just realized the cable I linked was for a Samsung galaxy. I'm not sure if it makes any difference, but to avoid confusion here's another example to avoid confusion

What is your longer-term goal after you get a keyboard working? I don't know what blackboard means in your thread. If you want something with processing power, why not considering raspberry pi?

Blackboard: a black board to write on with chalk.

If you want something with processing power, why not considering raspberry pi?

Its really just a quick project, and I don't wan't to stark anything new, like raspberry pi.

What I need help with is **a)**How to connect a keyboard to the due

b) a simple explanation of the USBhost library. Do you -have- to use usb.Task() or can you just use Keyboard.getKey repeatedly?

bestanamnetnogonsin:
Blackboard: a black board to write on with chalk.

Its really just a quick project, and I don't wan't to stark anything new, like raspberry pi.

What I need help with is **a)**How to connect a keyboard to the due

b) a simple explanation of the USBhost library. Do you -have- to use usb.Task() or can you just use Keyboard.getKey repeatedly?

a simple explanation of the USBhost library

Read your PM.

Oh sorry haven’t seen it until now :-[ embarrassing… but Thanks a lot!

One short question about the Library: Can I just use the Keyboard.getKey function inside the void loop()? Or do I -have- to use usb task?

Well anyway Then the only other thing I need to know is how to connect a keyboard with a normal usb plug to a DUE with a micro plug (will the adapter(s) I mentioned worK?),

I did not get into the code deep enough to see how the "events" / keyboard keys are detected.
While testing I noticed some intermittent delays using keyboard, mouse worked just fine.

You need to look into the keyboard controller class.
I may be wrong, but I think callbacks are used.

USB connectors pins are SAME irregardless of type or size.

But USB 2 and USB 3 are physically different.
I would check, out of curiosity , if the SAM3X8E native USB port can run USB 3.
Arduino Due hardware (mini plug) is for USB 2.