Getting Eleven to run USB Keyboard sketches

The "Eleven" is our Uno-equivalent Arduino-compatible board, but with a number of improvements including prototyping area, a mini-USB connector, LEDs mounted near the edge, and the D13 LED isolated using a FET. [Product page]
Post Reply
tburns
Posts: 2
Joined: Tue Oct 29, 2013 3:20 am

Getting Eleven to run USB Keyboard sketches

Post by tburns » Tue Oct 29, 2013 9:52 pm

I get an error message ("keyboard only supported on the arduino leonardo") when I try to upload any of the USB Example sketches onto the Eleven. From my reading I assume I have to upgrade the firmware of the 16U2.

Any advice on where to find a clear and complete guide on how to do this? Every guide I've found so far is for the Uno and not the Eleven and the physical placement of some key components is clearly different so I don't want to risk following them.

Thanks so much,

Tony

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Getting Eleven to run USB Keyboard sketches

Post by angusgr » Tue Oct 29, 2013 10:58 pm

Hi Tony,

That's correct, to have the Eleven behave as a keyboard you'll need to replace the 16u2 firmware. You can do this one of two ways, via DFU mode (no other devices required) or using an external programmer.

Once you replace the 16u2 firmware with a keyboard firmware then you won't be able to upload sketches to the main microcontroller (atmega328p) directly via USB from the Arduino IDE - you have to either use DFU mode again to swap back to the serial firmware to upload (then swap back) or use an external programmer.

To upload with DFU mode, the steps on the Eleven are basically the same as on the Uno. The only unclear part being how to get to DFU mode.

The pins to short across (5 & 6 - Reset and Ground) are shown here in red. They're in basically the same place as on the Uno:
Image

Steps to access DFU mode are:
1) Short the pins shown (you can do this by just putting a piece of wire in them, or you could solder a pin header there and use a proper 2-pin jumper if you think you'll be doing this a lot. I usually just use a breadboard jumper wire, held at an angle so it makes good electrical contact.)

2) Press and hold the main Reset button on the Eleven.

3) Without releasing the reset button, remove the jumper.

4) Release the reset button.

... and the 16u2 will come up in DFU mode where you can upload a new firmware as described here.

For alternative options, you could consider using an external programmer like our USBAsp - which allows you to program either chip through its six pin ICSP header, without messing around with DFU mode.

Or for a final alternative, a LeoStick is able to run keyboard sketches while still accepting uploads via "normal" avenues.

Please let us know how you get on.

- Angus

tburns
Posts: 2
Joined: Tue Oct 29, 2013 3:20 am

Re: Getting Eleven to run USB Keyboard sketches

Post by tburns » Wed Oct 30, 2013 8:35 pm

Thank Angus - a really complete answer and exactly what I was after. I suggest you make it into a tutorial as part of the main Freetronics site.

It was really useful to find out that the firmware upgrade would make subsequent sketch uploads trickier - thank you. So I have taken your advice an bought a Leostick.

Once I climbed the configuration learning curve, I was able to load and run the KeyboardMessage sketch - what a thrill to be able to count and display my button presses! But I do have greater plans for this capability.

Thanks so much. If I decide to upgrade the Eleven using your process (I have it because I bought the experimenters kit) I will let you know how it goes.

Tony

GraemeSPa
Posts: 15
Joined: Tue Sep 24, 2013 11:58 am
Contact:

Re: Getting Eleven to run USB Keyboard sketches

Post by GraemeSPa » Tue Dec 10, 2013 12:29 pm

In the Practical Arduino book, there is a section on USB keyboard with sketch and circuit to build - only the sketch won't compile on a Eleven R3 - the text refers to build 0016 - which i take as being one of the very early IDE builds and i found it on a very old and rusty website called code google. OK - i will try this when i get around to it. I have two questions to ask :

1 the circuit text refers to 3.6V zener diodes to limit the volts to 3.3V - why not just use 3.3V zeners in the first place? ( i got a bag full of these)

2 the book was written in 2009 - has the keyboard.h code not been updated since then to run on later IDE? This project seems to have been forgotten.

Changing the firmware in the usb chip as described seems a little complex to me - I'm new at this and want to keep the Eleven as my experimenter platform in one piece. Uploading sketches is one thing, but we're not all computer graduates out here.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Getting Eleven to run USB Keyboard sketches

Post by angusgr » Sun Dec 29, 2013 9:22 pm

Hi Graeme,

Sorry for the extremely long delay in replying!
GraemeSPa wrote: 1 the circuit text refers to 3.6V zener diodes to limit the volts to 3.3V - why not just use 3.3V zeners in the first place? ( i got a bag full of these)
I'm fairly certain 3.6V just happens to be the absolute voltage limit on a data line, as given in the USB specification. 3.3V should be fine as well.
GraemeSPa wrote: 2 the book was written in 2009 - has the keyboard.h code not been updated since then to run on later IDE? This project seems to have been forgotten.
It looks like the library "RancidBacon" produced for the Project Log: Arduino USB page doesn't work with later IDEs.

There's an updated version of the same project here that works with the 1.0 IDE:
http://blog.petrockblock.com/2012/05/19 ... n-example/

I'll suggest to Jon that he updates the code links to point to that library as a more recent alternative.
GraemeSPa wrote: Changing the firmware in the usb chip as described seems a little complex to me - I'm new at this and want to keep the Eleven as my experimenter platform in one piece. Uploading sketches is one thing, but we're not all computer graduates out here.
Agreed. The simplest option is probably still using a board with integrated USB like the LeoStick, but this approach is a good choice as well.

- Angus

Post Reply