hey im planning a project where i use a FSR(force sensor) and a throttle for an electric motor my plan is to program it like i was using a potentiometer based throttle but in reverse so when more pressure is applied the faster you go i'm still new to programming with an Arduino so can anyone help me figure out the code
You can use map to make your pwm output go with or against the analog input like this:
val = map(val, 0, 1023, 0, 255);
... or
val = map(val, 0, 1023, 255 ,0);
So what would this do for me if you would be able to explain
Well a pot or fsr in a voltage divider reads an analog value between 0 and 1023, and I'm thinking you will then use that to create a PWM output of 0 when the pot is 0, and 255 when the pot is 1023. You can easily reverse that relationship with map.
You might like to have a look at this tutorial which controls the brightness of an led; basically the same as controlling a motor speed.
You can make the force increase or decrease the speed, just by reversing the numbers in map() as I showed.
You need to control the motor speed first. Remember the Arduino can't source or sink much current, so you will need at least a transistor to give more current to your motor. See Overview | Arduino Lesson 13. DC Motors | Adafruit Learning System
Probably a better example is here: http://www.circuitstoday.com/pwm-generation-and-control-using-arduino
Substitute your FSR for the pot shown.
thanks that helps jimbo and i have a motor controller with a throttle input and im trying to use the fsr as that input instead of the twist throttle it came with