Author Topic: _delay_ms functions doesn't seem to work..  (Read 3470 times)

Prashant Gupta

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
_delay_ms functions doesn't seem to work..
« on: September 29, 2015, 11:40:05 AM »
I have written this code in user_prgm().
state is define outside user_prgm().

simAddStatusbarMessage("State " .. state)
         if (state == 0) then
            _delay_ms(2000)
            state = 1
         elseif (state == 1) then
            set_motor(cw_in_straight, ccw_in_straight)
            simAddStatusbarMessage("Going to wait after moving forward")
            state = 2
         elseif(state == 2) then
            _delay_ms(2000)
            simAddStatusbarMessage("Wait done")
            state = 3
         elseif(state == 3) then
            set_motor(255,0)
            simAddStatusbarMessage("Rotating the bot")
            state = 4
         elseif(state == 4) then
            _delay_ms(2000)
            state = 5
         elseif(state == 5) then
            set_motor(255,255)
            simAddStatusbarMessage("Rotation done")
            state = 6
         end

This code doesn't reflect desired behaviour. There is no delay in the movement of the robot or any apparent rotation.

What is the mistake here?

I have been referring to this thread.
http://www.k-team.com/forum/index.php/topic,911.0.html
Since it is very old, I started a new thread.