Interrupts Necessary ?

Hello,

I'm trying to make a homebot that can move with two bipolar steppers and detect if a obstacle is near with a SRF05 sonar.
My question is : Since Step() is a function that cannot be interrupted, how can I be sure that I still can detect an obstacle in front of me at all time ?
Shall I use interruptions ? Is there any tutorial then ?

Thx in advance !

How are you planning on generating your interrupt?

Since Step() is a function that cannot be interrupted

Can't you just make shorter steps?

If I were going straight forward this would be ok yeah. But if i've got a preprogrammed sequence I want my bot to follow with his two steppers, it may be no very nice to have lots of ligns which calls to the sensor function. Don't you think so ?

Don't you think so ?

Knowing absolutely nothing about your robot, it isn't possible for me to offer an opinion.

Still interested to know how you're going to get a range interrupt.

Okay :slight_smile:

My robot is just something composed by two steppers and a US sensor : SRF05.
I can control the SRF05 with that : http://arduino.cc/en/Tutorial/Ping?from=Tutorial.UltrasoundSensor
The steppers with that : http://www.arduino.cc/en/Tutorial/MotorKnob -- Bipolar with no potentiometer since I want to make a predeterined sequence.

I want my bot to do something like -- Forward (200 steps) -- Turn 90° left -- Forward 200 steps -- Turn 90° right .... etc ... and that if i put my hands in front of the sensor, the bot stops.

So, I can make it go forward and turn. But I don't know how to combine that with the fact that it must detect and obstacle and stop whatever it is.

I don't know if i'm clear enough ... hem ... so I've read that steps() can't be stopped. So, is it possible to do what i wish to do ?

Make smaller steps. Test for an obstacle. Then rinse and repeat.

can control the SRF05 with that : http://arduino.cc/en/Tutorial/Ping?from=Tutorial.UltrasoundSensor

Note that SRF05 != Ping.
I'm not sure how you can be using the code you linked to there.