ATMega328p chip (e.g. Arduino Nano) as a teensy alternative

Arduino/Teensy software/code questions and discussion
Post Reply
TimBer
Posts: 38
Joined: Tue Sep 13, 2016 1:42 am
Has thanked: 4 times
Been thanked: 11 times

ATMega328p chip (e.g. Arduino Nano) as a teensy alternative

Post by TimBer » Sun Oct 09, 2016 9:35 am

Ok.....

Let me start
bart_teensy.gif
bart_teensy.gif (30.37 KiB) Viewed 14026 times
When I was looking for a cheap teensy alternative it was late....I was feeling sleepy. I found something cheap and thought, let me order this.
Did not look at the fact it was an ATMega328p chip (Arduino Nano clone), not an ATMega32U4 (or something else with native USB HID support)

I ordered it at a chinees site, so during the wait (a couple of weeks), I decided to order some teensy alternatives as well.

Finally the Nano clones arrived and I decided to give it a go (still waiting on the teensy clones BTW)


Let me start by saying:
1. USBHIDDescriptors are terrible
2. A lot of examples on the web do not work or...
3. If you try to change something, everything brakes down :(

I got it to work.

You start with soldering an USB connection to pins D2, D4 and D5 using two zener diodes 3v6, two 68r resistors, one 2.2k resistor (I actually used an 1.5k resistor).

Use the following schema (taken from http://blog.petrockblock.com/2012/05/19 ... an-example):
schematic.jpg
schematic.jpg (30.77 KiB) Viewed 14026 times
I also found a library on this page that is based on the AVR VUSB library, but that was sending the keystrokes like a,up,a,up,a,up,a,up,a,up,a,up when both were pressed, when actually you want both the be sent simultanious.

So I changed it a bit.

Keep in mind you need to use the arduino software version 1.0.5 (not newer, I still need to look into that ).

I put the instructions and software on github:
https://github.com/beidehand/UsbKeyboard

in short:

1. use version 1.0.5 of the arduino IDE which you can find at: https://www.arduino.cc/en/Main/OldSoftw ... ases#1.0.x
2. after you install the IDE go to the libraries folder and add the files from this repository (located under libraries)
3. pins 2,4 and 5 are used for USB communications (D2, D4, D5 on a Arduino Nano V3) see schematic.jpg
4. solder the diodes and resitors to D2, D4 and D5 as shown in the schematic
5. pins 14,15,16,17 are actually analog pins(A0,A1,A2,A3), but the can be used as digital inputs as well
6. this software is pull-up, so your buttons should go to ground (not 5V or else). Use a common ground.

The pin setup for the keys is as follows:

define NUMBER_OF_KEYS 15

char pinCharacters[NUMBER_OF_KEYS] = { KEY_ENTER,KEY_RIGHT_SHIFT,KEY_Z,KEY_X,KEY_A,KEY_S,KEY_ARROW_UP,KEY_ARROW_DOWN,KEY_ARROW_LEFT,KEY_ARROW_RIGHT,KEY_K,KEY_Q,KEY_W,KEY_E,KEY_R};

int pinButton[NUMBER_OF_KEYS] = { 0,1,3,6,7,8,9,10,11,12,13,14,15,16,17};

meaning:

pin0 : KEY_ENTER
pin1 : KEY_RIGHT_SHIFT
pin3 : KEY_Z
pin6 : KEY_X
pin7 : KEY_A
pin8 : KEY_S
pin9 : KEY_ARROW_UP
pin10 : KEY_ARROW_DOWN
pin11 : KEY_ARROW_LEFT
pin12 : KEY_ARROW_RIGHT
pin13 : KEY_K
pin14 : KEY_Q
pin15 : KEY_W
pin16 : KEY_E
pin17 : KEY_R

Now load the ino file containing the arduino software for the board
Select the correct board and port to use in the menu's of the arduino software


I did not find any additional information on this in these forums.....that why I'm sharing.
If there are better options please let me know :-)

User avatar
Fleder
Posts: 849
Joined: Thu May 05, 2016 9:04 am
Location: Germany
Has thanked: 183 times
Been thanked: 258 times

Re: ATMega328p chip (e.g. Arduino Nano) as a teensy alternative

Post by Fleder » Thu Dec 08, 2016 1:37 pm

Wow, that's what I'd call a real hack.

Any videos of it in action, sending keyboard inputs?

TimBer
Posts: 38
Joined: Tue Sep 13, 2016 1:42 am
Has thanked: 4 times
Been thanked: 11 times

Re: ATMega328p chip (e.g. Arduino Nano) as a teensy alternative

Post by TimBer » Fri Dec 09, 2016 2:12 am

Fleder wrote:Wow, that's what I'd call a real hack.

Any videos of it in action, sending keyboard inputs?
No Video's yet. I was actually using this as a controller for an arcade cabinet I'm building, but I removed all wiring to start over, using multiple Pro Micro controllers.

For my GBZ builds I'm also using Pro Micro's now.......using an Atmega32u4 is way more efficient / adjustable.

I still have it with all the wiring , so I'll make a few pictures this weekend.

rainerwinkler
Posts: 1
Joined: Mon Feb 13, 2017 12:19 pm

Re: ATMega328p chip (e.g. Arduino Nano) as a teensy alternative

Post by rainerwinkler » Mon Feb 13, 2017 3:06 pm

Hi everyone!

I plan to build my first GBZ. Since I have laying around a bunch of spare arduino pro minis (with atmega328p chip) I was wondering if this could be a teensy alternative. After searching around I found this thread. Has anyone tried this VUSB solution? Is it a valueable teensy alternative? How is the input lag?

Thanks for your help!

TimBer
Posts: 38
Joined: Tue Sep 13, 2016 1:42 am
Has thanked: 4 times
Been thanked: 11 times

Re: ATMega328p chip (e.g. Arduino Nano) as a teensy alternative

Post by TimBer » Wed Mar 29, 2017 3:57 am

Sorry for the delay but:

I would not advice this. It is working, but you will have more flexability using a board with a ATMega32u4 chip.

Such boards only cost like 2 or 3 US dollars / Euro's.


Concerning input lag, I have not noticed lag when using this.

donnacarter0103
Posts: 1
Joined: Fri Apr 21, 2017 2:44 am
Location: USA
Contact:

Re: ATMega328p chip (e.g. Arduino Nano) as a teensy alternative

Post by donnacarter0103 » Fri Apr 21, 2017 2:55 am

Very interesting. It really very helpful for me. I using teensy and till now, haven't any problem but I finding top arduino alternatives. And it's too good for me. Thanks for sharing a great thing with us.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest