-- -- SharpTest v0.1 (ASkr 10/2009) -- -- Just some demonstrations about Sharp distance sensors -- ------------------------------------------------------------------------------------------------------------ -- uWait() -- -- Waits (blocks) for ~ us. -- Minimum value is ~80us -- Use this while in a nxt.DisableNXT(1) <-> nxt.DisableNXT(0) loop! ----------------------------------------------------------------------------------------------------------- function uWait(c) local i c=c*10 c=(c/24)-32 for i=1,c do end end ------------------------------------------------------------------------------------------------------------ -- utilWait() -- -- Waits (blocks) for ms. ----------------------------------------------------------------------------------------------------------- function utilWait(tim) local stim=nxt.TimerRead() repeat until nxt.TimerRead() > stim+tim end function s(port,count) local i local j local nIGS=nxt.InputGetStatus local nTR=nxt.TimerRead nxt.OutputSetSpeed(3,0x20,100) while nxt.ButtonRead() == 0 do end local toffs=nTR() for i=0,count-1 do j=nIGS(port) -- print(i,nTR()-toffs,j) print(j) end nxt.OutputSetSpeed(3,0,0) end