How to use potentiometer and adjust motor speed

How to control motor speed using potentiometer or e bike throttle.

Welcome, @Dino_X!

To control the speed using a potentiometer, you will need to attach it to an analog pin (there are lots of tutorials on how to do this), and then read the value.
You can then use the value you read to set the motor’s target speed in simplefoc.
The simplest way is analogRead(), but you may find this is too slow and affects the motor performance. In this case there are ways to read the value asynchronously, so that it doesn’t cause delays in your loop.

Have you set up a motor with simplefoc yet? I’d start with that and then add potentiometer control once the basic setup is working.

1 Like

Thank you for the reply. I’m working on Custom ESC for 48v 750W BLDC hub motor. My Circuit is working but it making more noise so I deside to implement FOC in my controller. Actually I’m using thumb throttle for control the motor speed.
Thumb throttle are using 49e hall sensor and it adjust the output signal based on the magnetic field

Hi @Dino_X

I’m looking to control a BLDC hub motor with potentiometer too. But I didn’t achive to use the Simple Foc library. Can you post your code here please ? For now I would just like to run the hub motor.

I am using Simple FOC’s PowerShield. I would love to see your code because even though the pinout must be different if your code is working I should only have a few small changes to make.

If you don’t know, to post code use this : ``` at the beginning and at the end of your code.

Thank you in advance for your response, looking forward to reading you.

See if this helps.