I am currently working on a project that will control long/lat motors on a machine lathe. This will be done by two methods...either RC control through 2.4 ghz receiver using pulsein or hardwired control using potentiometers to control motors (depending on position of switch). Presently hardwired method is working well except I would like to have more of a center zone where the motors are commanded to stop. I have the arduino interfaced with a sabertooth 2x25 using the serial packetized method. So far I am having no luck with my attempts. The program was taken from another writer and I have modified it extensively to suit my needs. Anyone have any info??? Pretty sure I am missing something simple!
To stabilize analogread() you can read multiple times and do some averaging.
int val = 0;
for (int i=0; i< 16; i++) val += analogRead(sensorPin1);
sensorValue_long = val/16;
val = 0;
for (int i=0; i< 16; i++) val += analogRead(sensorPin2);
sensorValue_lat= val/16;
The map function is for lineair interpolation, If you want to make a bigger deadzone the map() function is not usefull anymore.
Check the multimap function - Arduino Playground - MultiMap - as this allows you to do multiple mappings in one.
Sorry for the above post...Could not get the code to copy over with the proper formatting (only worked with the quote option). I included some conditional statements not complete yet to satisfy overtravel requirements, however, this is the code as it currently stands. Thanks Rob...I am in the process of modifying it per your suggestions. Any advice for the posting code since everyone else seems to be doing it properly.
Thank you Mark and Rob. Following your advice I was able to solve the issue. I now have a beautiful "dead" spot in the center of the pots. Unfortunately with the new code it exceeds the maximum allowed in post so I can't list it until I get this posting issue resolved. Wish you were closer so I could buy yous a beverage.