Hi, I'd like to use my Arduino Uno as the robot brain for a hexapod I'm building. The tutorial I'm referring to uses a wireless PS2 controller to control the hexapod, but I was wondering if it would be possible to send live joystick-like commands from my laptop to my arduino through serial communication in a similar fashion? Most of the resources I've found online do use serial communication for computer-arduino communication, but it seems to default as an "enter command here then press enter to send" interface, which is too slow for my liking. Is there a way to make it more immediate like a joystick/game controller, such that if I just press a button it'll send that input to the UNO and move the actuators?
Just enter joystick in the IDE library search and start perusing the examples.
Hi! Welcome to the forum.
Food for thought:
- The first thing you need to decide is which techology you will use to exchange data between the PC and the robot. Few of them are "Serial" like. You have basically wi-fi, classic Bluetooth, Low Energy Bluetooth (BLE) and RF. Each one of them have their pros and cons.
- The Uno doesn't have any wireless capabilities on its own. So, if you choose to keep it as the brain, you will have to buy other parts to add wireless capability to it.
If it was my project, I would abandon the idea of using a PC and would go with a cell phone. There are already some apps that emulate a joystick, you can use them to send the commands to the robot.
Serial Monitor from Arduino IDE is really simplified/stripped down example what can be done with Serial communication.
You may write program on PC in any language of your preference, which open Serial port to Arduino and communicate with it at full speed.
(Given BaudRate and Arduino capabilities. I suggest to use 115.200 baudrate instead of 9.600, as it is more than 10x faster.)
I would also suggest to use RTS/CTS (hardware) controll flow, where each of the two parties may say "wait moment, processing your data" and later "ready again, send more" to pause date from other side, so not lose anything, but it needs another Serial module and little modification on HW side as well as modification on SW side.
To say it in Shakespearean
wireless 'r not wireless yond is the questioneth
("Wireless or not wireless, that is the question")
Independend from that you will have to replace the controller handling in the Hexapod.ino file by your own routines (unless you want to emulate the PS2X_lib.h).
You are aware that there will be more to do? You will have to analyze the code carefully, remove unnecessary parts and replicate all inputs that originally are acquired from the PS2X Controller, okay?
Check if there are any handlings where two or more buttons are pressed in parallel. You will have to consider this as well in a PC user interface.
All of this is possible, but it may require some programming knowledge—both for the PC and for the Arduino.Please don't get me wrong—I don't know your skill level, after all!
Good luck!
ec2021
Hello all, I appreciate you taking the time to respond to my post.
Update: I believe I found a solution to the issue of sending automatic inputs (so no terminal prompt needed) from my computer to my arduino uno to control a servo. The Arduino IDE doesn't seem to support this functionality but I can use a third party IDE connected to the same COM to achieve this, a solution mentioned in this thread.
Upon further digging I found this tutorial, meant for connecting a gaming controller to the Arduino with an external IDE. But it seems to do what I need quite well. I can move my mouse to control a servo connected to my Arduino, and I believe I can build a virtual controller functionality on top of this for my hexapod.
You don't need to use the IDE to send serial commands to the Arduino you can use any software that provides a serial output