The following code is for the bird project but has not been tested as i currently need to purchase another BAP.
Its function is designed to start working as soon as power is applied. The example i have written at this point is for the eye blinks only.
For the programmers out there, does this look correct?
My expectations for this test code is that once power is applied, the eye lids will start in the open position (1500) then blink slow then fast.
If this is the correct way to use the HServo command then i can start programming the other routines.
[code];------------------
Enablehservo; Activate HSERVO function
;Servo pin connections
Blink con 0
Head_Rotate con 1
Head_Left_Right con 2
Head_Front_Back con 3
Neck_Front_Back con 4
Neck_Right_Left con 5
Wings_OC con 6
Left_Wing con 7
Right_Wing con 8
;Variables
cBlink var Sword
cHead_Rotate var Sword
cHead_Left_Right var Sword
cHead_Front_Back var Sword
cNeck_Front_Back var Sword
cNeck_Right_Left var Sword
cWings_OC var Sword
cLeft_Wing var Sword
cRight_Wing var Sword
;[Init]------------------
;HSERVO [pin\pos\speed]
;pin =
;pin number to generate servo signal on
;pos =
;position to move servo arm too. range ±12000.
;position is in clock cycles(1/16000000 of a second,.0625us), centered at 1500us
;speed =
;how fast to move to new position. Must already be at a known position to use.
;First time using HSERVO should use a speed of 0. Speed of 0 means move to position immediately.
HSERVO [Blink\1500\0]
HSERVO [Head_Rotate\1500\0]
HSERVO [Head_Left_Right\1500\0]
HSERVO [Head_Front_Back\1500\0]
HSERVO [Neck_Front_Back\1500\0]
HSERVO [Neck_Right_Left\1500\0]
HSERVO [Wings_OC\1500\0]
HSERVO [Left_Wing\1500\0]
HSERVO [Right_Wing\1500\0]
pause 100
;------------------------------------
;************************************
;[MAIN]
Main
;HSERVO [Blink\1500, Head_Rotate\1500] ’ Send control pulses to servos
gosub Center_ALL
pause 3000
gosub Blink_Active
pause 1000
Goto Main
;************************************
;------------------------------------
;Sub Routines
Blink_Active
HSERVO [Blink\1500\0] ’ hold open
pause 1000 ’ for one second
HSERVO [Blink\12000\255] ’ Close eys slowly
HSERVO [Blink\1500\255] ’ Open eyes slowly
pause 2000 ’ for two seconds
HSERVO [Blink\12000\0] ’ Close eys fast
HSERVO [Blink\1500\0] ’ Open eyes fast
return
;------------------
Center_ALL
HSERVO [Blink\1500\122]
HSERVO [Head_Rotate\1500\122]
HSERVO [Head_Left_Right\1500\122]
HSERVO [Head_Front_Back\1500\122]
HSERVO [Neck_Front_Back\1500\122]
HSERVO [Neck_Right_Left\1500\122]
HSERVO [Wings_OC\1500\122]
HSERVO [Left_Wing\1500\122]
HSERVO [Right_Wing\1500\122]
return[/code]