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.

Simple ATTiny13 Servo Tester with BASCOM

Status
Not open for further replies.

HarveyH42

Banned
Finally nailed it! Can't believe how simplistic it turned out to be. I wasted so much time trying to get the Config Servos command working, and failing. So, I started playing with Pulseout and some LEDs, and it just sort of clicked.

Anyway, here's the code if anyone is interested. The servo control signal comes off pin 5. Used the 4.8 Mhz internal oscilator.

Code:
$regfile = "attiny13.dat"
$crystal = 4800000

Config Portb.0 = Output
Dim A As Word
Do
For A = 1 To 20
Pulseout Portb , 0 , 1500
Waitms 20
Next
For A = 1500 To 1000 Step -10
Pulseout Portb , 0 , A
Waitms 20
Next
For A = 1 To 20
Pulseout Portb , 0 , 1500
Waitms 20
Next
For A = 1500 To 2000 Step 10
Pulseout Portb , 0 , A
Waitms 20
Next

Loop
End

Starts the servo in the center position, goes right, center, left, and repeats...
Might not be going fully to either extreme, but will be good for the project I needed servo control over.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top