-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sending controller inputs via arduino instead of python? #8
Comments
I don't see anything that looks incorrect from a first glance, but it's hard to say. Unfortunately due to work/moving I don't have a lot of time to debug this. What I would recommend is trying to compile the emulator emulator (yeah, I know, sounds funny) - if you install socat, run make and then make run-emu, it runs the same code that would run on the Arduino as a binary using emulated serial ports via socat. See SwitchInputEmulator/Arduino/Makefile Line 68 in 397c149
You can try piping the Arduino's (the one running the script) serial input/output to this file and then see what's going on by inspecting the traffic. If you need more help with this, I can answer questions for issues you might run into. |
Hi, I've recorded some communications between the arduino and the emulator, and i've found something interesting. Here's a log from the arduino to the emulator (I used interceptty to log the communication): Any ideas on why this might be happening? |
Just want to make sure, you have the Arduinos wired up correctly right? TX->RX and RX->TX. |
Yep |
I have a similar problem. I have compiled Joystick.hex and flashed it to my Arduino Uno R3. The device is properly recognized as a gamepad and it sends the default controller state (centered sticks and no buttons pressed). I'm using a USB to Serial adapter (TTL, FTDI FT232RL chip) and wiring it as follows:
The adapter is recognized as a serial (COM) port. However, even if I send bytes (using the provided script or by other means) the Arduino doesn't send back responses. The adapter has a LED that lights up when it's transmitting to the Arduino and I can confirm that data is being sent to the board. However, the LEDs in the Arduino board are always off and the computer doesn't get a response back. |
The Arduino flashed with Joystick.hex effectively bypasses the ATMega328p on the board and uses only the ATMega16U2 (the microcontroller handling USB comms). That should always be plugged into a device. Having said that, I realize now that I might have gotten the wiring order wrong when I described it here. The TX/RX pins on the Arduino are relative to the ATMega328p. So the ATMega16U2's RX is connected to the ATMega328p's TX pin (as labeled on the board) and vice versa. So you should probably try connecting the adapter's TX to the Arduino's TX and RX to RX. |
Thank you so much. It's working now for me. |
@TeslaBolt see above for fixed wiring instructions. My bad. I'll keep this issue open until I get around to fixing the README. |
@wchill Thanks for the notice about the wiring, however I tried that and it still doesn't work. The joystick flashed arduino does get recognized my computer so that isn't an issue, so I guess the issue lies in my 2nd arduino (the one sending the serial from my rewriting of the code), or the code itself, even though my 2nd arduino does work correctly when connected to the emulator. I guess there's something not communicating right between the 2 arduinos specifically. |
@TeslaBolt I want to try something similar, did you ever get this to work? I'm going to try your code EDIT: Your code works. Only made some small adjustments |
(First off, sorry if this isn't the correct place to ask this)
I am trying to create a controller for the switch, and ideally i'd want the same arduino checking buttons and communicating with the switch (this is after I get this step working though).
I have successfully used the client.py script to communicate and send commands to the switch, so I thought that if I recreate the script in arduino, it should work for my purpose.
(Instead of PC -> Serial Adapter -> Arduino (Joystick.hex) -> Switch, i'm trying to use
Arduino (running script) -> Arduino (Joystick.hex) -> Switch
Well, I've done that (except for the testbench functions) and it doesn't work (I can't tell exactly why, but i'm pretty sure it's just not syncing).
Link to arduino code: https://pastebin.com/XWmZmS7y
Is there another way to approach this, or are there any mistakes in my code that is causing it to not work? (I am new to arduino programming and serial communication stuff)
Thank you, and again I apologize if this isn't the right place for this.
The text was updated successfully, but these errors were encountered: