AMDPlayer DownloadAMDConverter Download Log Sniffer Chat Client Service Installer
Home VROOM Lego Learning My Sites About Me
< Back

The first challenge we were presented with was to make a robot that follows a black line using only one light sensor. It might not sound like much, but it's fairly complicated to get it to act the way you want. There's a lot of factors that play into it all of the sudden.
Jump to video:
Follow Line
Avoid Obsticle


As you can see my first attempt was a lot of code. It worked, but not well. What it did was to drive forward when it was on the black line and when it detected white it started to search for the black line by "scanning" left and right while increasing the search area each time.

I rewrote it and it ended up looking like this:


As you can see, a lot less code, but same outcome. It still searches but instead of writing the same command everytime with slightly larger parameters it runs inside a "for" loop that increases the search every time it completes a cycle. It still wasn't good enough. i kept ajusting it but to no avail so i came up with another idea. Why not attach another motor that rotates the light sensor so that it looks on each side of the black line? GREAT idea........ in theory...


In theory it sounds like it could work but in pratice it really doesn't. The motor is too slow to turn the light sensor, so the robot actually runs off track inbetween readings... No good then.
Ib, our teacher, came with a subtle hint that i might want to go for the "gray" line instead (the point where the black line meets the white paper). Great idea! Started programming......

Took a while, but this program runs really smooth, not the fastest, but smooth. What it does is to constantly try and be on the edge of the line. The way it does it is by reading the light level as a gradient level. If it gets darker it turns right and if it gets lighter it turns left.
The night before the compatition i had an idea on how to make the calculation for the motore better so the robot (hopefully) would run faster.

Success! After a bit of finetuning this was a success, the best result i had gotten. As an added bonus you can see the code is shrinking quite a bit as well, so efficient code don't need to be massibe. ;)
Here's a video showing the result:



Back to top

There was a second part of the challange. Avoid an obstacle. I didn't really spend that much time programming that part, so the code is somewhat messy.

As the observant reader might have noticed, this program is based on the second to last of the line following programs. The reason for this is that as i didn't spend that much time on this part of the challenge i didn't get to make the code effecient and as a result it slows down the whole program. The final line following program suffered too much because of that and the robot ran off the line, so i decided to use the second to last as that one didn't run fast enough to suffer too much. Here's a video of the result:



Back to top

Contact:

Social:
Facebook


= 0