I have been looking for documentation about adapting teensy projects to run on arduino but haven't find anything. What considerations must I take in order to adapt the code, and also to make the proper physical equivalent connections on my Arduino?
Running your PS3 Gamepad code on Arduino Uno
(4 posts) (2 voices)-
Posted 3 months ago #
-
I'm afraid I don't have any direct experience in this area.
For starters you will need to set the MCU type in the Makefile (line 58) to at90usb82 for the UNO's USB chip. You will also need an AVR programmer to flash via ICSP interface.
In my gamepad.c file you will need modify all the if statements. They currently sample the digital inputs on the teensy board and set values in the USB report accordingly.
I believe the UNO uses a serial interface between the Atmega8U2 and the ATmega328. So all of the if statements would be replaced with code that samples the Atmega8U2 serial port.
My recommendation would be to make a sketch that reads digital pins on the Arduino and writes out a series of bytes to the serial port that matches the gamepad_state_t struct (see gamepad.h line 9). The digital pins you choose is up to you just don't use pin zero or one since those are used by the serial port. Write and test the sketch by watching the serial monitor in the Arduino software on your PC.
Then in your gamepad.c file you need to read from the Atmega8U2 serial port. I'm not sure what the exact code would look like, but here is some pseudo code:
// read from serial port directly to USB report buffer read_serial((uint8_t*)gamepad_state, sizeof(gamepad_state_t));Posted 3 months ago # -
Thanks for the tip. I have a free week near and will try what you recommended .
Posted 3 months ago # -
Feel free to post questions if you run into any snags. I will try and offer any help I can.
Posted 3 months ago #
Reply
You must log in to post.