We are trying to run a RC solar car project and instead of using a bluetooth module we are trying to incorporate a joystick module. Here is the code for the project with bluetooth.Code
How would we change the code to include a joystick instead. We found this code online for coding an analog joystick to an arduino, will this work?
So why not let us in on the rest of the code as well? If it was in that Google docs link then pleas post it here in the correct way, which you now know.
Is there anything wrong with the code you did post? Is it working correctly?
Oh sorry. So here is the code from the project on the instructables.com website - RC Robot Car With Solar Panels. This original project uses a bluetooth module, but we want to use a joystick instead and we just want to take out any bluetooth module code (that would control the car with an android/app) and put in the joystick code. But we are sure if 1) the joystick code is correct for this project? and 2) where to place the code in the existing code for the project?
Can you explain more about how you want to use the joystick with the robot?
Do you want to send x-y joystick values, instead of commands, to the robot by bluetooth?
How do you want the robot to respond to those values? Do you want to map 7 different x-y joystick outputs into the 7 individual character commands, or do you want to use the joystick in a different manner.
I am not sure. We want something simple, preferably not bluetooth. Can we add an IR receiver? Whatever you think will require the least steps and troubleshooting. We just simply want to control the car with one joystick. Here are the components we are using so far:
At least 2x solar panels
1x battery 9v - rechargeable
1x lithium battery 9v
2x battery clips
1x Arduino Uno Rev3 or Mega 2560
1x bluetooth module - PREFER NOT TO USE
1joystick module - THIS IS THE NEW COMPONENT WE ARE ADDING, NOT PART OF THE ORIGINAL PROJECT. Do we also need a IR Receiver?
I sense that you are trying to cobble together a project without any real idea of what you are doing. Just searching for stuff that sounds like part of your project and then not knowing how to incorporate two ideas together.
The coding involved in doing this is almost trivial.
Rule 1 - Never use Instructables to learn anything. They are almost universally poor, written by people with an inflated view of their own skills. Only use that site if you can spot the errors that will inevitably be present.
Rule 2 - Never use code that you don't understand.
From what I gather you want to use analogue pots to produce digital control, that is just a left / right / or nothing (centre), is this correct?
If so start off by defining, on pencil and paper, what you want the motor to do for each three states of each of the two pots.
Then work out what motor control pins need to be set at what level to achieve this. How are you going to control the stop / go of each motor?
When you have this sorted only then will you be able to begin coding. When you have had a try at this coding and get stuck, that is the time to post on a forum for help.
Make sure you post the code you are having trouble with and include a schematic of your hardware. You will need one of these before you can even consider building it. Note a schematic is not a Frtizing layout diagram, a hand drawn sketch will be fine.