Squarebot - Line Following

As part of my physics class we are building a squarebot. We had to set a task. we chose to make it use a the line following kit to navigate to a trashcan, and shoot a ball into the can using a servo as a catapult. Building it was a breeze but our teacher wants us to program it to be fully autonomous. This is where we have run into problems. None of us are programmers so we have absolutely no idea what we are doing. We are supposed to be done with the project next week and our grades depend on the success of this robot. PLEASE HELP?!?!?!?

just a suggestion, i would use sonic sensors, or program the bot (from a set starting point) to go a certian distance, stop, then go another set distanse, stop, then (with the trashcan in front of the robot, now, launch the projectile. see the gallery for a diagram

Since you used the “we” word, I will assume you have a team.
One group to work on line follow, the line follow kit likely came with some code. Load it, run it, tinker with it.
One group on catapult launching. Design, build, program (which could be as simple as when end of line, run that motor).
Work in bits.

In addition to what cat said, when working with code write out what your plan is ,roughly, just so that when you sit down at the computer you have a general written idea of what you plan to do. If you have trouble with the code itself post a screenshot of your code and I’ll, we’ll help.

We finally got it to follow the line, now the problem is how do we get it to follow the line, then use the servo, then turn around, re-aquire the line and follow it back to where it started?

For the turning around and reacquiring the line part it’s actually pretty simple. I’m assuming you’re using two line following sensors one for each side of the line right? If so then just use the to count the lines. Before you turn around one sensor will be on each side of the line. So if you tell the robot to rotate left the left sensor will see the line. Then as the robot keeps turning the right sensor will see the line. At that point you would want the robot to stop turning and return to following the line. Hope this helps.

I’m curious. Weren’t you supposed to learn how to do these thing as part of the classroom training you got before being assigned this project…? Are you asking us to do your homework for you?

These questions are pretty basic. How does your teacher expect you to accomplish them without your having at least rudimentary programming skills? Maybe it is time to have a consultation with him/her?


All technichalities included, I belive we aren’t exactly handing him all the answers, though his teacher a suppose does not expect him to be going to the forums either…

Just curious… instead of having the bot turn around and re-acquire the line, can’t you just have it follow the line backwards after it fires the projectile? It would already be on the line and have acquired it. Or will the line-follower not work when it is behind the bot at that point?

Just brainstorming…


We weren’t taught anything before hand. It would be wonderful if we were. Our advisor doesn’t know how to program either, therefore I have been pouring myself over the forums for hours upon hours trying to figure this out. My teacher knows about me being here, so no worries, ya’ll arent doing my homework for me.

Following the line backwards in an interesting idea. All you would have to do is reverse the code for following it forwards. Depending on the drive train though it could be harder since the front of the robot would be “off” the line before the back…

Robot setup is a squarebot with 3 line following sensors mounted on the front. Would reversing the code work?

I think it probably would only one way to find out.

I honestly don’t think you can reverse the code like that. I think you would have to back the squarebot up, away from the trashcan, and spin around, then go back to the line, make the ~90 degree turn (the “~” was on the count that easy C will not make a 100% 90 degree turn, it can be close, but not exact)

Here is a very rough sketch of the setup. http://www.flickr.com/photos/8152687@N05/488716949/
We got the robot to follow the line, now we need it to activate the servo at the end of the line, then follow the line back to its beginning. I am going to try to put up the code in an hour or two but As it is programmed now, the line follower code is in a while command, we cannot figure out how to make the servo go only once at the end of the line … any suggestions? … If seeing our code will help you, I will have it up no later that 5 pm today … hopefully it will be up shortly after 4

Well i guess the picture didnt work. It is a typical squarebot with a servo and three line sensors mounted on the front. Attached is the program we have now. Nothing outside of the while loop is working. I am using easyc v1.x I accidentally opened the files in an evaluation version of easyc pro. I dont know if this will cause any problems.
Line follower.zip (1.67 KB)

One thing you will want to think about as you work through this problem: How will you verify your catapult is always pointing the same direction when it gets to it’s stopping point? A line follower may not be reliable enough to meet this requirement. A catapult can be very consistent as long as it is consistently positioned when fired. I was able to program a trebuche vex to roll away from a target, turn 180 degrees, and fire a projectile back into the target using an optical encoder and a lot of trial and error. Good Luck! http://www.youtube.com/watch?v=iLFhnW71pjk

We finally got the robot to work! Thank you all for all of your help!
I will post the code later if anyone is interested.

Yes, we are interested! Please post the code you used. It’s the least anyone could do for all of the help received. Also, please post pics of your fine bot.

Congrats on getting it to work!


Made a 100 on the project!!! here are some robot related goodies

The Team
Follow the link for a video of our success on the first run!