Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; AntiBotCaptcha has a deprecated constructor in /homepages/8/d680172117/htdocs/QA/qa-plugin/q2a-captcha-antibot-master/AntiBotCaptcha.php on line 22
How to control Temp. Using StepperMotor and PID? (school requirment help) - Electronoobs Q&A

7 Online
0 Member And 7 Guest
Today Visits : 942
Yesterday Visits : 2665
All Visits : 192405

Welcome to Electronoobs Q&A, where you can ask questions and receive answers from other members of the community.


+1 vote
Hello Electronoobs,

I am Ralph an Electronics Engineering Student, thank you so much for the tutorials, i have learned things i dont get from school.

I need help!!!

Using your code, how do insert a code if temperature is higher than set point, i want my stepper motor to rotate clockwise but if temperature is lower than set point i want my stepper motor to rotaye cointer clockwise
asked by (250 points)

1 Answer

0 votes
If you use the A4988 driver, just make a code something like this:

If(temp > setpoint)






digitalWrite(direction, HIGH);


That will change the direction. Then all you need is to create a loop of square pulses for the steps.
answered by (33.4k points)
Thank you so much for the reply!  but i have a concern.

Will the PID control the speed of the rotation?
Is it ok to use L298N instead of A4988?
Like if the setpoint temperature is 100°C and the real value is 110°C i want my stepper motor slowly rotate the gas valve so that the temperature will be equal to the setpoint not rotate entirely to turn off the gas flow.

Which part in the PID code will I insert the stepper motor code