Page 1 of 2

Teensy code = Arduino code?

Posted: Wed May 25, 2016 2:43 am
by Fleder
Hello there fellow Sudomodders,

I bought myself some cheap Arduino Nano clones and now i have to burn the bootloader onto them, because they do not already have this.
Well, after that, i want to try if they are a viable alternative for the Teensy LC Board, but i am not sure if one could just use the same code for the Teensy provided by wermy or if the Arduino Boards use their own language.

Can someone enlighten me here and maybe even provide some tutorials on how to programm for arduino/teensy?

Thank you and regards

Re: Teensy code = Arduino code?

Posted: Wed May 25, 2016 3:45 am
by tmscaf
Not quite an answer to your question but I caught in your post that wermy posted his teensy code? If I understood that correctly, do you have a link to that page? I'd love to see what he did for his buttons. Thanks!

Re: Teensy code = Arduino code?

Posted: Wed May 25, 2016 7:25 am
by wermy
Hey,
Arduino is more of a brand, and as you've discovered there are hundreds of Arduino-compatible boards out there now. Generally speaking yes it's all Arduino code. The main differences will be which pins do what (some boards might have analog inputs where others have digital, some boards might have a built-in LED on a particular pin that differs from an official Arduino, etc.).
Another big difference is what kind of chip they use. Not all Arduino-compatible boards can act as a USB HID device (keyboard, joypad, etc) -- it's mainly the 32u4-based ones that are able to, I believe.

Hope this helps!

Re: Teensy code = Arduino code?

Posted: Wed May 25, 2016 7:51 am
by Fleder
tmscaf wrote:Not quite an answer to your question but I caught in your post that wermy posted his teensy code? If I understood that correctly, do you have a link to that page? I'd love to see what he did for his buttons. Thanks!
Sure, here you go: http://sudomod.com/wp-content/uploads/2 ... y_Zero.zip
But follow his Tutorial for the whole process and software.
wermy wrote:Hey,
Arduino is more of a brand, and as you've discovered there are hundreds of Arduino-compatible boards out there now. Generally speaking yes it's all Arduino code. The main differences will be which pins do what (some boards might have analog inputs where others have digital, some boards might have a built-in LED on a particular pin that differs from an official Arduino, etc.).
Another big difference is what kind of chip they use. Not all Arduino-compatible boards can act as a USB HID device (keyboard, joypad, etc) -- it's mainly the 32u4-based ones that are able to, I believe.

Hope this helps!
Hey wermy,

thanks. So is there a difference between a Teensy LC code and an Arduino Nano V3 code, if they both can act as a USB HID device?
I just want to know how to tell my Arduino to do the same as you did with the Teensy LC in terms of Button inputs.
That should not be really difficult if they both accept the same programming language, am i right?

It would be a huge price difference if i get my Nano clones to act as an viable alternative to the Teensy LC.
I just don't know anything about how to programm a Teensy or the Arduino Boards and Clones.

Re: Teensy code = Arduino code?

Posted: Wed May 25, 2016 8:10 am
by wermy
@Fleder
Honestly I'm not sure. :\ Looking at the official Keyboard library page, they don't mention the Nano -- only 32u4-based boards: https://www.arduino.cc/en/Reference/MouseKeyboard

And then looking at the HID library (which you'd use if you want to use it as a joypad) they don't mention the Nano anywhere, but they do say "Any other 8u2/16u2/at90usb8/162/32u2/32u4 compatible board": https://github.com/NicoHood/HID

The Nano looks to be based off of the ATmega328, which of course is not in that list: https://www.arduino.cc/en/Main/ArduinoBoardNano

So if I had to guess I'd say it doesn't look like it will work. But I'd say it's worth a try, especially if you already have the boards. :)

Re: Teensy code = Arduino code?

Posted: Wed May 25, 2016 10:42 am
by Fleder
wermy wrote:And then looking at the HID library (which you'd use if you want to use it as a joypad) they don't mention the Nano anywhere, but they do say "Any other 8u2/16u2/at90usb8/162/32u2/32u4 compatible board": https://github.com/NicoHood/HID
It seems that the ATmega328 does not have a USB driver, so it is not possible to use those boards as a USB input device.

But, thanks to you and the link to the HID library, it seems that the ATmega32u4 has got this feature and is able to function as said USB input device. Or at least i hope so. So it is still possible to find a cheaper Teensy LC alternative, even if it is not as cheap as the Nano V3 clones.

But, as i see, the Teensy needs 3.3v input. As the 32u4 is available in 3.3v and 5v versions, would it be better to go with 5v or the 3.3v version?

Re: Teensy code = Arduino code?

Posted: Sat May 28, 2016 9:30 am
by Fleder
Today, my Adruino Leonardo Clone arrived, it is really small and has the 32u4 chip, which should work as a USB HID.
The only problem? I can't use your Teensy code, somehow.
It tells me this, if i try to programm it:

Code: Select all

C:\Users\***\Desktop\GBZ\Game_Boy_Zero\Game_Boy_Zero.ino:2:20: fatal error: Bounce.h: No such file or directory

 #include <Bounce.h>

                    ^

compilation terminated.

exit status 1
Error compiling for board Arduino Leonardo.
But i also included the bounce.h in the directory, which was not necessary for the Teensy LC.
Do you have any idea why this code would not work on a Arduino compatible board?

Thanks in advance [mention]wermy[/mention].

Re: Teensy code = Arduino code?

Posted: Sat May 28, 2016 9:31 pm
by Helder
I hope you can get this working as I'd like to use the same IC in a build.

Re: Teensy code = Arduino code?

Posted: Sun May 29, 2016 3:13 am
by Fleder
After searching a long time, i think i finally wrote a code that works, the problem is, those clones do not come with a button to put them into programming mode.
If you programm them as a USB HID, you won't be able to reprogramm them without erasing the rom.
There is a trick that i heard of, where you need a jumper to be set and if you remove this, it does not go into USB HID mode.
But i have no idea how to do this, does someone else heard of it or know how to accomplish this?

Thanks

Re: Teensy code = Arduino code?

Posted: Mon May 30, 2016 12:56 pm
by wermy
Fleder wrote:After searching a long time, i think i finally wrote a code that works, the problem is, those clones do not come with a button to put them into programming mode.
If you programm them as a USB HID, you won't be able to reprogramm them without erasing the rom.
There is a trick that i heard of, where you need a jumper to be set and if you remove this, it does not go into USB HID mode.
But i have no idea how to do this, does someone else heard of it or know how to accomplish this?

Thanks
Sorry for the delayed response. There's no way to reset it? That is frustrating. Have you poked around in the Arduino menus (the Tools menu specifically)? I've used some types of boards before that I had to manually select a reset type. I'm not sure if that's any help with your board. Here's an example from an Adafruit Wifi Arduino board I've used (this menu doesn't show up for every board, though):
Image