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
fozbstuios
  • 23
  • 4

3 Answers3

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.

Craig
  • 2,120
  • 10
  • 11
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

mpflaga
  • 2,523
  • 14
  • 13
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