NXT LEGO Bots
On the first day of robotics we all went over and constructed a LEGO bot (I was singing 12 days of christmas to first sentance). We used NXT bricks for
the bots we constructed. We connected our computers to these with bluetooth and then programmed them with python. Only the IDLE(Python GUI) 2.6.6 worked
with pyblocks so we had to find that on our computers. Then we began programming first using an already made one then using our own things. We had to move
forward with a command called "bot.forward" which normally just goes forever. Then we had it wait for a certain time with sleep and then used "bot.stop"
to make it stop. We were given the challenge of having it move in a square. To do so we had to make it turn with "bot.right" or "bot.left". However, this
is much like the "bot.forward" command so we had to stop it. Also, we had to make sure it had the right amount of time and speed set to it for a 90 degree
turn. Here is the code I used in order to program a square turn:
This is a basic version of the bot that I made while following a basic online tutorial at:
On the second day of bot making we updated our bot with both physical and program modifications. At first we made the bot move around and move away from
things if they touch things. Here is the code used to do that:
Then we went over and started using the sonar to try avoiding the objects. The sonar is used to sense the distance between the bot and the object. We
fixed up the commands so that the bot would back up and turn around before touching an object. Here is the improved code:
We made a lot of improvements to the touch sensors and at the end we added unnecessary accessories such as weapons. I wish I had a camera to take a
picture of the finished bot.
On the third day of robotics we went over and tested things with color sensors. At first we were going to have the robots search for a red ball and signal
once they found it. However, because the color sensors didn't work for anything past about a centimeter and the sonar didn't work with at the same time
as the color sensor, we decided to have it follow blue lines instead. I had programmed the bot to move forward if the color sensors sent blue but turn
if the sensor sensed anything else. In this way, the color sensors would move along the line and turn if it was veering off the line. Here is a picture
of the code I used:
If I had more time to work on this, I would have made the code so that the robot would actually stop when the touch sensor was pressed. Although I included
code for it to do so, the code for some reason never worked. Also, I would have fixed the robot so that it would change the direction it turned in based
on the direction it turned last. Again, I put the code for it but it didn't work.
Mars Rover Remake!
On the last day of robotics we went over and we made our robots act as if they were seaching Mars. Most people were programming the bots to move around
craters in the board by sensing them with the sonar. Then they would alert if the bot found the "water" when the color sensed the blue spot. We made our
robot use the fact that the color sensor would sense black when it didn't have anything near the sensor. Then I made it move around when it sensed black.
Here is the code for that:
Although it may have been a good idea, it had some problems in it. The bot began to sense black because of its shadow which messed everything up. Due
to this unexpected turn of events, the bot ended up failing. However, if we set it up in a good lighting then it would still work. Another problem we
found was that the bot didn't react fast enough in order the avoid falling into the craters sometimes. In order to prevent this I tried making it move
slower and even take interval rests. This seemed to make it a bit better but it still didn't completely work.