📄 servo.bas
字号:
'----------------------------------------------------------------------
' (c) 2000 MCS Electronics
' examples that shows how to use Servos
'----------------------------------------------------------------------
'First we tell the compiler how much servos we want to use
'and to which pins they are connected
Config Servos = 2 , Servo1 = P3.5 , Servo2 = P3.7 , Reload = 100
'The maximum mnumber of servos to use is 16
'The RELOAD value is the step value. In this example 100 uS is used
'You could use a lower value for a more precise stepping
'Now we want to control the pulse duration
'A normal servo has a range from 800-1600 uS and 1200 is the middle
'Each value is 100 uS so for 800 we specify 8
Dim Key As Byte
Servo1 = 8 'to the left
Servo2 = 16 'to the right
Do
Print "*"
Wait 1 'this will take some longer because of the interrupt used
Key = Inkey()
If Key = 49 Then 'if we press 1
Servo1 = 12 '1200 uS
End If
Loop
End
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -