Robotics

We used a Lego robot kit and followed the instructions to make a working robot that we can control through Bluetooth on our computers.


Sensors on the Robot

The sensor on the left is the ultrasonic sensor. The sensor in the center is the color sensor. Finally, the sensor on the right is the touch sensor.

Moving

After building the robot, we tested whether it would be able to move by programming it on our computer. We used the command bot.forward() to make the robot move forward. It would not stop until we command it to stop with bot.stop()


Ultrasonic Sensor

Out of all the sensors, our ultrasonic sensor was the first one that we were able to make it work. In Python, we type in the line sonar.get_sample() in order for the robot to give us a number based on how many centimeters the robot is from a wall or any surface in front of it.

The next day, we programmed the robot to turn around once it sensed that there was a wall in front of it.

These pictures show the robot after we attempted to connect the three sensors better. The "tail" in the back of the robot is our attempt to protect the robot in case it backs up into another robot or wall.

Our goal was to make the robot avoid everything when the robots fight. With this code, we combined the code for the touch and ultrasonic sensor to do that. We added a message to be printed when the touch sensor was pressed.

On Friday, we made our robot detect the edge of the desk and programmed it to back away. This allowed the robot to stay on the desk forever.

When the robot's ultrasonic sensor is off the desk like this, then the robot will back away from the edge.

In this code, we changed the speed of the robot because it was driving too fast. When it did this, it was hard for the robot to turn before it fell off because it was going too fast.


Touch Sensor

For the Scatterbot Challenge, we tried multiple times to get our code for the touch sensor. We wanted the robot to stop once the touch sensor is pressed. After a lot of help, the robot was able to do these actions.

This is the code that will make the robot move forward until the touch sensor is pressed. This piece of code says that the bot moves forward when the variable thisistrue is true. Once the robot's touch sensor is pressed, thisistrue would be set to false and the robot will stop moving forward.


Color Sensor

We wanted our robot to stop once it senses a certain color. For this, we used this code:

It it similar to the code for the touch sensor because both of the have the same function. They just take different inputs. One of the few differences is that once the robot finds the designated color, it prints out the message "I found blue," or any other color we wanted.

The robot was taking in the black color of the carpet until it found the blue tape on the ground. It then printed "I found blue."

The following day, we attempted to make the robot follow a colored line. The line was in an "L" shape and was in blue tape.

The farthest we were able to make our robot go was right at the turn. The color sensor was able to keep our robot on the straight path despite the slight angle our robot makes when we use the forward command. Once the robot reached the turn, it went off course because the robot was slowly turning away from the robot.

This is our code for the walk the line challenge:

We wanted to make the robot "scan" its surroundings so we made the robot turn left and right for a certain amount of time in order to look for the blue tape again.