0

I've been working on a DIY keyboard project I have all the hardware designed and now its time for the code. For the microcontroller, I'm sort of locked into an Arduino UNO r3 as I already have it lying around. I know it doesn't have HID capabilities baked in, but I can flash different firmware to it. At first I was going to go with a generic HID firmware. This approach was problematic because it would require me to first write/send my Arduino sketch, then touch I wire to various portions of my UNO (it isn't SMD). After this, I would flash the HID firmware and hope that there were no bugs in my sketch as fixing bugs would have required flashing Arduino firmware and repeating the aforementioned steps. I then had the idea to use Teensy firmware (https://www.pjrc.com/teensy/). This approach seems better, but I have questions regarding its feasibility.

  1. Can I upload Teensy programs/sketches to the Arduino after I've updated its firmware (if I had a real Teensy I could do this via the teensyduino plugin)?

  2. Similarly, I'd like to write some software that allows me to remap the keyboard. Would the Teensy firmware allow this?

  3. Does the Arduino have enough memory to support #2?

  4. Is it possible to reflash BOTH the 8u2 and the 16u2 on my UNO (for details see #2 in update one below)
  5. If 4 is possible is it possible to write code that would read/write the flash on the 8u2 as a filesystem? (for details see #2 in update one below)

Would the teensy firmware be a good option given these constraints? I know I've focused mainly on the Teensy, but if you have a more straightforward approach I'd love to hear it. Also, I know Arduino has a keyboard library(http://arduino.cc/en/Reference/MouseKeyboard) but, it seems rather basic, seems to block other keyboard signals while in use, and isn't easily remappable(see #2). I haven't completely written this off, so if you think this would be the best option please let me know. Thanks for any and all help.

Update Thanks to one of the questions linked by @Ignacio Vazquez-Abrams(Can the 2nd MCU on the UNO R3 be used for keyboard emulation?) on the original question(weirdly it didn't show up here) I have learned the following things(not necessarily from the question itself but by links provided in it):

  1. the Atmel 8u2 of the UNO has 8kb of flash while the 16u2 has 16kb (should've known) I still don't know if either of these sizes are enough to hold my Teensy code AND 1+ map files generated by the mapping software I would make. (see #2 above)
  2. the 8u2 seems like the chip that tinkers are generally advised to reprogram as it wouldn't hold the Arduino sketch. If I'm uploading teensy firmware I shouldn't need Arduino sketch capability (Teensy has that built in) So What I might do is use the 16u2 as a place to hold the firmware my code and use the 8u2 as a filesystem to hold any maps I'd like to store. This leads to more questions see the newly added 4 and 5
2
  • @IgnacioVazquez-Abrams I don't think that the question you reference or the question that it was marked as a duplicate of answer my question. From my point of view, they are more general (asking how/if the UNO can be reprogrammed to emulate keyboards, while mine asks about the feasibility of one specific approach. Thanks for the extra reference though.
    – fozbstuios
    Jun 8, 2014 at 23:08
  • Reading that question and all the other related questions will allow you to make an informed decision regarding your plan. Jun 8, 2014 at 23:30

3 Answers 3

0

No, you can't put the teensy bootloader on the UNO. The teensy has an ATMEGA32U4 and the UNO has an ATmega328. The 32U4 has USB support in hardware the 328 does not.

The UNO does have a ATMEGA16U2 which does have USB in hardware like the 32U4 but it is programmed as a USB serial converter (to replace the FTDI chip used in earlier arduinos).

It might be possible to install a modified teensy bootloader on the 16U2 but that wouldn't help you because it is not connected to any of the I/O pins on the UNO.

In any case to install new firmware on the 16U2 you would need to buy something that can program the 16U2 via the ICSP and if you are going to buy something you might as well just buy a Leonardo or Teensy since they already support emulating a keyboard.

Now if you really wanted to spend the time it might be possible to write your own bootloader for both the 16U2 and the 328 on the UNO in such a way that they emulate a teensy or Leonardo but it won't be easy, and you would be limited by the smaller memory available in the 16U2.

5
  • So your basically recommending Teensy? I may be in luck, someone offered to give me one
    – fozbstuios
    Jun 9, 2014 at 16:57
  • I am recommending getting a board that already can do what you want. Either the Teensy or Leonardo can do it. If you have existing shields the Leonardo may be a better choice since it has the standard Arduino layout.
    – Craig
    Jun 9, 2014 at 17:03
  • No shields are needed. Going with the teensy since it is free.
    – fozbstuios
    Jun 9, 2014 at 17:31
  • See my answer from arduino.stackexchange.com/questions/1840/… . The end is same goal. Where I recommend a Leo.
    – mpflaga
    Jun 9, 2014 at 17:39
  • You actually do not need a ICSP programmer for the UNO's 16u2, as it supports DFU. Unlike the 328's bootloader is replaced. But for the cost, I would suggest getting a Programmer.
    – mpflaga
    Jun 9, 2014 at 17:41
0

Teensy uses a proprietary boot loader called half K (as in 500 bytes). Doubt one would get the source or image to burn into the 16u2.

Where you can get 8/16u2 USB to HID code examples here: https://github.com/harlequin-tech/arduino-usb

1
  • Thank you while that does look interesting, I've decided to go with the Teensy (actual physical device). This way I have the key64 firmware to piggyback off of and can be sure that I have enough space
    – fozbstuios
    Jun 9, 2014 at 18:14
0

Its is possible and very easy to do. See the HID Project and the Hoodloader: https://github.com/NicoHood/HID https://github.com/NicoHood/Hoodloader

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.