Hi Everyone,
I've made an RC transmitter and RC tank and am having big problems with the tank receiving (and reacting) to the drive signals. The code has 2 main parts, tank drive, and headlights on/off.
The headlights on/off code works by itself, and when i serial print what the tank is receiving from the transmitter (left joystick, right joystick, headlight mode, drive mode) and its onbaord photoresistor readings, the serial monitor displays it correctly. I can start to see some problem when i move the joysticks, that the serial monitor display slows down.
When i add the code to analogwrite the joystick data to the motors, here's where the big problem is. The robot doesn't respond. I hear the motors whining, but they are not moving. Then out of nowhere they move. Same with the headlights, its as if the arduino receiver is getting overloaded, and then at some random point decides to respond to the data.
Might anyone be able to look at my robot code and figure out which part is causing the arduino to be erratic/unresponsive? I really look forward to solving this and i'm really stumped at the moment.
Just to make the code a bit clearer...
Transmitter
This has a counter called lightMode that counts 0,1,2 when the user presses a button.
Also has a counter called driveMode that counds 0,1,2 when the user presses a button.
Theres also a bunch of code for a "fake" menu system. There are 9 text screens, and when a user presses either the headlightmode or drivemode button, it looks like they are selecting an option from a menu. But in fact the whole display is being changed.
Receiver/Robot
when it receives lightMode 0, it turns the headlights off
when it receives lightMode 1, it turns the headlights on
when it receives lightMode 2, it checks a photoresistor and turns the headlights on if its too dark, and off when its bright enough
when it receives driveMode 0, it lets the user control the robot skid steering using the joysticks
when it receives driveMode 1, (not as yet implemented because i'm having issues just adding the driveMode 0 code) it lets the user control the robot skid steering using the joysticks UNTIL the front Sharp IR sensor detects an obstacle, then it takes away control form the user and reverses, then gives control back to the user.
when it receives driveMode 2, (not yet implemented) the robot drives forward by itself, stops reverses and turns a bit when it encounters an obstacle, then continues forward again.
The robot is just a mish-mash of wires and motors until I can get the code working

I've attached the code, and look forward to as much assistance as possible.
I was inspired by the below instructable to make my robot, but the instructable-robot didn't have proportional steering so i decided to make my own.
TXv12.ino (13.3 KB)
RXv10.ino (4.46 KB)


