Dim T1 as single, T2 as single, T3 as single, T4 as single, T5 as single, T6 as single
dim servostackvar (1 to 60) as byte
dim minpulse as single
dim maxpulse as single
dim pulsewidth as single
dim refreshperiod as single
dim startvar as byte
dim sliderstart as byte
Sub Main()
call flashme(2)
minpulse = 0.001
maxpulse=0.0015
pulsewidth=maxpulse
refreshperiod=0.02
startvar = 0
sliderstart=1
T1 = timer
T3 = timer
T5 = timer
This is where I call the task
calltask "servotask", servostackvar
call putpin(9,0)
do
T2=timer
T4=timer
This is checking to see if any words have been recognized
if getpin(12)= 1 then
startvar=1
sliderstart=0
end if
if getpin(10)=1 then
startvar=0
sliderstart=1
end if
if getpin(17)=1 then
startvar=0
sliderstart=1
end if
if getpin(18)=1 then
startvar=0
sliderstart=1
end if
this is where the pulse to turn on the voice recognition is
if (T2-T1) > 5.0 then
call putpin(6,1)
delay(0.5)
call putpin(6,0)
T1=T2
end if
this starts the slider
if sliderstart=1 then
call putpin(16,1)
call putpin(5,0)
if (T4-T3) > 6.0 then
call putpin(5,1)
delay(0.5)
T3=T4
end if
else
call putpin (16,0)
end if
call sleep(0.02)
loop
End Sub
sub flashme(byVal flashx as byte)
dim x as byte
debug.print"RESTART"
for x = 0 to flashx
call putpin(25, 0)
delay(0.1)
call putpin(25, 1)
delay(0.1)
next
call putpin(26, 0)
end sub
this is the servo tasking
sub servotask()
do
do while startvar = 1
T6=timer
if (T6-T5) > 7.0 then
call putpin(9,1)
T5=T6
else
call putpin(9,0)
end if
call pulseout(11,pulsewidth,1)
if pulsewidth >= minpulse then
pulsewidth = pulsewidth - 0.000015
else
pulsewidth=maxpulse
end if
debug.print "hi"
call sleep(refreshperiod)
loop
loop
end sub
back to how