Let's Make Robots!

emekbot - a PID controlled robot

turn towards given heading, accept some commands
527458_10151872458107837_485811624_n.jpg73.27 KB

I have updated the code, and made a project page for it on github. PID now works nicely.

This is my experiment. It has a LSM303 compass, an arduino nano. Compass is mounted at a tower. There is also a bluetooth module that will send data. I am using the arduino PID library to turn towards a heading. The results are much nicer then using if else type clauses to find the heading. There are however some jittering. I will be posting the source code also. The loop is designed such that it can accept commands and do other things, while the bot is moving. I am a professional coder and this is my little experiment as to what can be done with a primitive platform such as arduino.

Here are code highlights:

1. non-obstrusive loop. for example, when the robot is executing a command, it can perform other tasks. this was hard to accomplish. in my first version, i could not send an emergency stop signal, while the robot was executing some task. but now, with each loop it will do whatever adj is necessary, and then go on to next task. for example if you send 's' over bluetooth, it can stop.

2.will accept commands over bluetooth serial. here are commands:

'c' will return current heading

'h180' will make it turn to 180

's' emergency stop

3. there is a PID control loop. what i have done is to set the target variable always to zero. process variable is angular difference between targetHeading, and currentHeading. the output is used to control motors. I can not say it is perfect yet, but it works. The heading algorithm now works perfectly. 

No delay statement is used while looping, and it samples the compass and adjusts motors at 200Hz.

Here is the project page on github


Comment viewing options

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

Tha arduino boasts way more resources than the first actual computers, sadly as RAM and stuff increases bloatware also increases, in 10 years a simple blink program will be a good megabyte in size lol

Maybe "low spec" or "low end" would be more appropriate terms than "primitive" =)

Do you have any plans for nagivation based tasks or anything like that?

-The Power Of An Arduino, Arducopter, for example, is based of an Arduino, and is a pretty advance multicopter system.

Anyway... your bot is pretty awesome, can't wait to see what other cool stuff you come up with! :D

ok, maybe saying arduino is primitive is a little bit overdose. i love the arduino, because i am thinking it as a teaching platform. but still, making things the right way is a little diffucult with arduino. 

i am waiting for comments and review for my code.

best regards,




Nice bot,  all you need now is some wheel encoders, and your on your way to building a bot that can navigate to any given X,Y, cordinate.  I was using a HMC6352 compass which was jittery, but I wrote an averaging program to smooth it out,  I now use the HMC5883L which is much better.


do you care to post your code for the averaging? i have done averaging, but the regular averaging is problematic when the bot is moving (turning) 

i think lmr could get much better if everyone was posting their code.




I'm using the parallax propeller, so my code won't be much use to you.

But basically you keep reading samples, say 10 or more, take the average, then reject the first sample and replace it with a new one, and average again, repeating in a loop.  I dedicated one processor to compass functions only, but you may not be able to do that on the arduno. ( the loop that is)

Not to parrot everyone but the Arduino is defiantly not primitive.  Having coded years ago I find myself enjoying the Arduino because I now have to eliminate all unnecessary code to fit everything in.  Everything takes consideration.  How long do I want the battery to last how much speed do I need what tools can I add.  The options are endless.  If I needed even more code I could read in command from an SD disk.  A little tricky but do able.