Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Control position of servo motor

Status
Not open for further replies.

Wingmax

New Member
sevoCont.jpg

With little modification from the previous program (Driving a servo motor-Timer0, Timer2), we can control the position of the servo motor.

View attachment servo_con.txt

A switch is connected to PortA.1 and PortA.2.
The shaft will be at the middle position first. When switch_A is pressed, it'll move one step to the left. When switch_B is pressed, it'll move one step to the right.
 
  • Like
Reactions: vdd
Cool. Thanks mate. I just cut and paste some of your codes and modified a bit, and it works for my project.
 
This is not a super accurate positioning control program. It's more like RC car or joy stick control.
The servo motor position is controlled by the input pulse width. If you read my program , you'll find that each time a button is pressed the pulse width is adjusted by +/- 80uS. The starting position is in the middle. So each time a button is pressed, the shaft is moved away from the middle position by the pulse width of 80uS.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top