Robotic arm, burglar alarm and advanced line following.

Robotic Arm

We built and programmed a robotic arm. It worked by rotating 3 different motors in response to the buttons being pushed on the lego brick. So the operator would push the left button and the arm would rotate to the left and so forth for right, up, down etc.

Here is the code involved. The commented code is for rotating the robot arm to the left, rotating the robot arm to the right is very similar it only changes the direction of the motor  and waits for commands from a different button. This is a very good example of students learning how to use WAIT blocks. In effect they are “Do Until” commands.

Left and Right code

Up and Down Code

Rotating the Drill code.

Robotic arm in action.

Burglar Alarm.

The burglar alarm was built and programmed to use an Ultra Sonic sensor and a colour sensor. The colour sensor was used in ambient light mode to detect whether it was day or night. The alarm was only to be active when it is dark. The Ultra sonic sensor was used to detect any objects that would appear in front of the sensor. When something was detected an alarm was sounded. The Ultra Sonic sensor would also rotate when the alarm is active. This  code is a really good example of using nested conditional statements.

Burglar Alarm Code.

Burglar Alarm.

(Unfortunetly I didn’t take any pictures or videos of the burglar alarm so here is a picture of our new dog Winnie)


Advanced Line Following.

This is a more advanced version of a program that we have developed previously in Week 3 of Term 1. However that program has some limitations so we played around with some more advanced versions. Instead of just turning left and right we would attempt to turn left and right depending on the amount of light that is coming back from the colour sensors. The robot would also attempt to turn left and right when the colour green is detected at an intersection.

Advanced line following code.




You Might Also Like