How would I increase motor speed as a result of a potentiometer increase?
I was thinking about this also. I was thinking about maybe setting the value of the potentiometer equal to the power of the motor, but with that you have to some math because the motors are limited to -127 to 127 and potentiometers are 0 - 4095. So you just have to figure out how to make 4095 = 127 and then 2047.5 = 0 and 0 = -127. This is just an idea I’ve brainstormed not sure if it will work but best of luck to you.
or just have 0 = 0 and then increase until 127 = 4095
thanks
I was thinking
potentiometer value =motor value(32.2)
but what would the code look like?
void (sensorvalue(potentiometer/32.2)==motor[rightMotor]);
task main();
It would look something like:
#pragma config(Sensor, in1, pot1, sensorPotentiometer)
#pragma config(Motor, port1, driveMotor, tmotorVex393_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
while(true)
{
motor[driveMotor] = SensorValue(pot1)/32;
}
}
Are you hoping to make a sort of knob that you can spin to adjust the motor speed?
Just do a map, by normalizing and then lerping. You can use the ranges of -127 and 127, and 0 and 4095. If you don’t know what I mean, just do a quick google for normalizing and lerping.