Teensy code = Arduino code?

Arduino/Teensy software/code questions and discussion
User avatar
Fleder
Posts: 848
Joined: Thu May 05, 2016 9:04 am
Location: Germany
Has thanked: 182 times
Been thanked: 257 times

Teensy code = Arduino code?

Post by Fleder » Wed May 25, 2016 2:43 am

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

tmscaf
Posts: 2
Joined: Tue May 24, 2016 11:42 pm

Re: Teensy code = Arduino code?

Post by tmscaf » Wed May 25, 2016 3:45 am

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!

User avatar
wermy
Site Admin
Posts: 1344
Joined: Tue May 03, 2016 8:51 pm
Has thanked: 618 times
Been thanked: 1319 times
Contact:

Re: Teensy code = Arduino code?

Post by wermy » Wed May 25, 2016 7:25 am

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!
ImageImageImageImage

User avatar
Fleder
Posts: 848
Joined: Thu May 05, 2016 9:04 am
Location: Germany
Has thanked: 182 times
Been thanked: 257 times

Re: Teensy code = Arduino code?

Post by Fleder » Wed May 25, 2016 7:51 am

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.

User avatar
wermy
Site Admin
Posts: 1344
Joined: Tue May 03, 2016 8:51 pm
Has thanked: 618 times
Been thanked: 1319 times
Contact:

Re: Teensy code = Arduino code?

Post by wermy » Wed May 25, 2016 8:10 am

@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. :)
ImageImageImageImage

User avatar
Fleder
Posts: 848
Joined: Thu May 05, 2016 9:04 am
Location: Germany
Has thanked: 182 times
Been thanked: 257 times

Re: Teensy code = Arduino code?

Post by Fleder » Wed May 25, 2016 10:42 am

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?

User avatar
Fleder
Posts: 848
Joined: Thu May 05, 2016 9:04 am
Location: Germany
Has thanked: 182 times
Been thanked: 257 times

Re: Teensy code = Arduino code?

Post by Fleder » Sat May 28, 2016 9:30 am

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].

User avatar
Helder
Trailblazer
Trailblazer
Posts: 2813
Joined: Thu May 05, 2016 8:33 am
Location: Rogers, AR
Has thanked: 1421 times
Been thanked: 3082 times

Re: Teensy code = Arduino code?

Post by Helder » Sat May 28, 2016 9:31 pm

I hope you can get this working as I'd like to use the same IC in a build.
My Sale Threads:

Retro PSU, 3.5A output!


Chat with me and other members


Don't contact me about obtaining my board files (as you will not get them). Don't contact me about any of my boards if they are sold out, they will be restocked as soon as I can get them.


Don't support thieves like ckliang who copied my AIO to resell and is now cloning the mintyPi, support the original creators and not the thieves!

User avatar
Fleder
Posts: 848
Joined: Thu May 05, 2016 9:04 am
Location: Germany
Has thanked: 182 times
Been thanked: 257 times

Re: Teensy code = Arduino code?

Post by Fleder » Sun May 29, 2016 3:13 am

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

User avatar
wermy
Site Admin
Posts: 1344
Joined: Tue May 03, 2016 8:51 pm
Has thanked: 618 times
Been thanked: 1319 times
Contact:

Re: Teensy code = Arduino code?

Post by wermy » Mon May 30, 2016 12:56 pm

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
ImageImageImageImage

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests