procfanousek
Member
Hello everybody,
I am kindly asking for help. I built a walking robot - inspiration from here: http://www.lollybotrobotics.co.uk/resources.html
I would like the robot to beep while turning. I cannot achieve this. I tried multitasking with start0 and start1 where start1 handled the beeping but it did not work. Maybe the 08M2 is too busy handling the servos. I was only able to make sound before it starts turning and I learned at Let's make robots that is better to add command low after sound command to let the corresponding pin be at log 0. Can anybody advice? Thank you for help. Code is attached:
I am kindly asking for help. I built a walking robot - inspiration from here: http://www.lollybotrobotics.co.uk/resources.html
I would like the robot to beep while turning. I cannot achieve this. I tried multitasking with start0 and start1 where start1 handled the beeping but it did not work. Maybe the 08M2 is too busy handling the servos. I was only able to make sound before it starts turning and I learned at Let's make robots that is better to add command low after sound command to let the corresponding pin be at log 0. Can anybody advice? Thank you for help. Code is attached:
Code:
rem c.1 servo
rem c.4 servo
rem c.2 HC-SR04 trigger
rem c.3 HC-SR04 echo
rem c.0 piezzo
#no_data
symbol time1 = 100
servo c.1,150
servo c.4,150
pause 500
main:
pause 10
pulsout c.2,5
pulsin c.3,1,w1
pause 10
w1 = w1*10/58
;sertxd ("w1 = ",#w1," Cm ",cr,lf)
pause 50
if w1<15 then
gosub turn
else
gosub walk_forward
endif
goto main
#rem
servos_mid_position:
servo c.1,150
servo c.4,150
pause 20
return
#endrem
walk_forward:
servo c.1,120
pause time1
servo c.4,120
pause time1
servo c.1,180
pause time1
servo c.4,180
pause time1
return
turn:
sound c.0,(120,50,0,50,120,50,0,50,120,50,0,50) low c.0
for b1 = 1 to 5
servo c.4,120
pause time1
servo c.1,90
pause time1
servo c.4,180
pause time1
servo c.1,150
pause time1
next b1
return