Let's Make Robots!
steven_x_test_code.pde5.16 KB

Hi I am Steven X I am a modified line follower chassis and serve as a test platform.

Now I will let my builder talk since i do not have any idea what he is doing with me.

Tests are the following:

  1. check distance in front, if distance is < than 20cm stop both motors
  2. execute a sensor sweep left and right and keep the left and the right distance in a variable
  3. compare left and right distance
  4. go to the direction where is more clear space

This is my second project and i used a line follower chassis to mount all the parts i need.

As you see i used the chassis to mount the gear motors, battery and sweep servo.

The leftover of the DVD case (see my Insect Robot) was used to attach the ulra sound sensor to the sweep servo (micro servo...very cheap but have to do the job)

Don't wonder...i will explain the LED's hanging around later ;-)

I put an old DVD (not old but ...let's say not worth to keep) above the motors and the servo to velcro the Arduino on it.

I used two distance pieces and the sweep servo is just mounted with one screw on the base chassis.

Behind the servo is the H bridge for the motors, the space for the Arduino was not enough, but maybe later if I like this little guy I will replace the current Duemilanove with a Nano...but i lost the thread....ok...DVD...

How to attach the DVD on the distance pieces if there is no hole in the top. I will tell you. Burn two holes in the DVD (probably you can not watch it anymore after this action but hey...robots are much cooler than boring movies), pull a cable binder (learned you guys call it cable tie)through the two holes and the one hole on the distance piece...done (see two pics above).

That's it. Nothing else done in terms of mechanics or moving. Right now i am trying to get the programming done. I am a little bit rusty in programming since i did nothing serious in the last couple of years. I could just search for code which is already done by others but that's no fun, i wanna solve this by myself... at least till a certain point.

For testing my code it's not good when this guy is running around, right?

So I put two LED's on the left and the right side to tell me when the motor should run. I am still in the sensor reading and checking the distance left and right after came to an obstacle. Now the sweep servo turns from 90° to 180° then to 0° and then back to 90°

By 180° it's executing a distance measuring and also by 0° Then it compares this two values and will turn to the side with the bigger value of distance. (ok not exactly...right now it just light up the LED on the side where he will go). This is also the reason why no video exists. As soon as he moves the video will follow.

UPDATE April 22 1:18am:

I got the first rough programming done. Steven X is now moving towards until a obstacle is closer than 20cm. If that happens he will do a sensor sweep left and right and compare the values. He will go to the direction where is more clear space ahead.

Please also see the (low quality) video. I built a trap that I can take the video without to chase him through the whole apartment.


1. Any smaller angel than 30° to a wall will not let him stop

2. The turns are just 200ms motor power on...will see if i can change this to a smarter solution


1. Can i do a continous sensor sweep and check the values in each loop?

2. How to get the turns smarter without wheel decoder encoders?

UPDATE April 25, 10:49am:

After 15 hours in the plane (yeah we was waiting 3 hours to fix a mechanical problem and then for take off clearance in Shanghai. Now 10,000km away from home i will improve the program and post the code in my description.

UPDATE April 25, 11:23am:

Test code is attached now. Please feel free to check it and feedback me if you see that i was totally wrong ;-)

UPDATE May 18, 10:27am:

Did a test run with the Sharp IR sensor and it went well. Now I consider it done and will further use it as a test patform for other sensors, attachments etc.

...oh yeah...about the name...will tell you later ;-)

Ok, now the thing with the name. I got this idea from the DVD i used. It was/ is the movie "Driven to Kill" with Steven Seagal :-) Not a good movie so the DVD did a good job afterwards....










Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
birdmun's picture

I noticed that, if there was a perfect storm of events leading to Steven X driving into a corner @ 45 degrees, Steven X will become stuck. Maybe adding an if/then case where left=right initiates a back-left or back-right to change the PING data. You also mentioned off axis detection was not so good. Maybe adding an off axis scan, not 90 but 45 degrees from center, to your main loop would help avoid shallow corners. Also rather than sweeping to the position, just digital.Write(FORTYFIVE) 'FORTYFIVE being the number required to turn the servo 45 degrees off center.

PS Thanks for sharing your labor of love. :)

lumi's picture

...but I am on it :-) Thanks birdmun I will see if I have ime t implement this during my next test. Right now it's dis- and re-assembled to test a Sharp sensor (without sweep) I might consider to use two of them to check the left and the right for a clear path.

However, the sweep looks much cooler than just driving the clear path and nobody know how he did it ;-)

Korel's picture

This is the original code from frits project. Thanks again frits.


Hope it will help lumi :)

lumi's picture

Yeah, will convert the code in Arduino language first ;-) But right now i do not have time since my daughter need my full concentration since she is playing with things she don't sould touch... :-)))

ignoblegnome's picture

My robot Penny's code is based on a straight forward translation of the Start Here robot from Picaxe to Arduino. I've made many changes since then, but the basic code may get you started.

lumi's picture

Cool, this will give me some ideas about the coordination of sweep and motor control.

Thanks ^_^

Korel's picture

Thanks IG I already had it in my collection and will take a look at it for sure. Might help lumi if he wants to. Take care my friend :)

Korel's picture

Yes true you are using arduino not picaxe...sorry about that. Let me know once you'll have the code please because I have one too and might look at your code and study it. Take care and have a nice day :)

Korel's picture

Hi Lumi, Thanks for visiting my project. Sorry if I didn't answer sooner...the reason is I forgot to check if anyone added a new comment.Better later than nothing :-) I'm also very busy reading others projects,which are very interesting and I'm also learning from you guys.

Thanks for your kind comment. I updated this robot by adding a green led forward and a red led reverse. Also added a piezo that make sound when the robot reverse or when too close from an objet that makes it go reverse. I also added a Sharp IR sensor for edges detecting when it's on a table or near a stair,but I disconnected it because the robot was acting weird with it. I didn't update my project yet because I figured that is was minor add-ons...but I will.

I'm also busy trying to learn C arduino language and trying to compare both boards and their features.I already have the Arduino Duemilanove,so I'm learning right now. Will keep up :-)

lumi's picture

yeah, i am learning alkso from the guys here. this is a really good community.