Speed control 12v motor using foot pedal

Hi, I'm working on a project which requires a foot pedal speed control of a 12v motor, I thought this would be a simple off the shelf thing but turns out all the sewing machine pedals are 110-220v, I have a hunch someone is making cheap PWM pedals somewhere but can't find any,
My next move was to buy one of those POT pedal components off eBay (link below) they are used for electric bikes etc.. I made a simple PWM dimer function on my uno using a 10k POT, this worked fine, I thought I could simple swap out the 10k POT for the POT pedal l bought, however it didn't work well, it did dim, but has a severely reduced range of dimming, any help as to what to do next? calibrate for the new POT? buy a better quality one? any help appreciated.

No "link below" and no code. But maybe using the map() function to convert the output of your thing to whatever range you need would do it. A restricted range for a basic pedal is not unusual because a foot pedal can't move the internal pot through anything like the full 270 degrees.

Steve

Apologies, My bad,

{int potPin = A1;
int readValue = 0;

void setup() {

pinMode(10, OUTPUT);

pinMode(potPin, INPUT);
}

void loop() {

readValue = analogRead(potPin);

readValue = map(readValue, 0, 1023, 0, 255);

analogWrite(10, readValue);
}

https://www.ebay.ie/itm/Crazy-Cart-Electric-BIke-Scooter-Shift-Foot-Pedal-Throttle-Accelerator-Control/163190168205?hash=item25fee45a8d:g:68EAAOSwQrJbaTj0

Looks o.k. so put a Serial.println() in to check the minimum and maximum values you get from the analogRead(). If it meets its specification they should be about 160 to 870. Then plug those into the map() instead of 0 and 1023.

Steve

Have a look at flyby wire throttle pedals used on cars - these often have two pits inside ( to check each other)?; you might be able to get off eBay

slipstick:
Looks o.k. so put a Serial.println() in to check the minimum and maximum values you get from the analogRead(). If it meets its specification they should be about 160 to 870. Then plug those into the map() instead of 0 and 1023.

Steve

Cheers! that done it! here's what works for the pedal linked {readValue = map(readValue, 185, 877, 0, 255);}
I'll have to wait until I rig it up to a mort to see if its smooth enough, seems like a rather basic pedal, very short throw.

@Sean2222

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.