I have completed a small project using an existing 433mhz remote handset, UNO clone, L298N dual motor controller(ebay) to control 2 12V DC motors on a self propelled and remote controlled golf cart. Too cumbersome to connect motors at this time so I am reading voltages at the output of the L298N when running tests. Standard assembly of the hardware with serial input on pin 2. Everything works as is should. The 3 directional buttons and stop button on the remote send the signal and I get the correct readings at the output of the L298. I am hoping to use this in the real world but cannot as it currently works.
Two problems.
- It is not practical or safe to run the device at full speed or near full speed.
There are conditions when it needs to run slowly, so i need to find a way to vary the speed. Searches indicate this can be done through better coding and i will address this at the last stage of the project, although any insight now would be welcome. - I think this may be and issue with serial communication. 90% of the time this device runs it is moving straight forward. As DC motors have different efficiencies and the device operates on uneven surfaces it drifts in one direction or the other. On the original controller I would just push one of the directional button and jog it back on line and it would continue to move forward. With the existing hardware and code, if I push a direction button it will continue to move in that direction until I push the forward button again. This too is not practical. Preferably the unit will always move in a forward direction with only small input for the directional buttons.
Can someone confirm if the existing components can achieve this type of control or do i need different hardware?
My coding skills are very weak. I was able to combine codes from few similar projects to come with the attached code.
Any help is appreciated.
trial2.ino (2.12 KB)