Possible to run Teensyduino code directly on Arduino MEGA?

Status
Not open for further replies.

jarrodb291

New member
Is it possible to run the Teensyduino code directly on an Arduino MEGA? In particular I'm interested in running the USB FlightSim examples directly on a MEGA that I already have connected to buttons and encoders
 
Just give it a try. Load the Teensy code into the Arduino IDE with the Teensyduino plugin installed. Select the MEGA in the tools menu and click verify. If the code is not compatible, the compiler error messages will inform you on where in the code the problems are.
 
When I change the board from Teensy++ 2.0 to MEGA 2560 several of the #include... lines change color. When I click verify it says that it can not find various .h files. Do I need to just track these down and copy to a new folder together?
 
No. Missing includes means that corresponding hardware specific libraries do obviously not exist for the Mega. Copying the Teensy specific libraries over and including these to a Mega sketch will most probably not work since the CPUs are different. You‘d rather have to find somewhere the needed Mega specific libraries.
 
Specifically the Mega has a USB serial chip + the main CPU so it will only ever be able to present as a USB serial device. Teensy can be a wide range of USB devices, driven by the loaded software
https://www.pjrc.com/teensy/td_flightsim.html
So to use the existing Mega+connected hardware you need to bridge serial only data into whatever your flight sim needs (you do not say if this is actually X-plane). Doing that will involve either a driver of some sort on the PC side parseing USB serial to whatever X-plane needs or a Teensy running USB flight sim talking to the mega via some interface effectively using it as a port expander.
 
It would likely be easier to make a Teensy 3.x to Arduino Mega2560 shield adapter. No porting effort needed, and you re-use all of your buttons and encoders. Plus you get all the USB capability of the Teensy, the better support, and lots more memory and speed.
 
Status
Not open for further replies.
Back
Top