Browsing Category

Slideshow

Slideshow

Gyroscope and Voting Machines etc.

During the last two weeks we developed two different robots. One was using a Gyroscope and the other was was a voting machine. Following is a description of these two robots. The new kids worked on the Beginner programs.

Gyroscope.

The Gyroscope is used to measure 2 values;  how many degrees a robot has turned from a starting point, and the rate of turn. So we can measure how far a robot has turned and we can measure how fast it is turning.  This allows us to create more accurate robots. For example we previously  programmed a robot to drive in a square, where we estimated how far the wheels needed to turn in order to make a 90 degree turn. This is quite difficult due to the influence of different surfaces on the traction of the wheels. However when we use a gyroscope we can measure how far the robot has turned and so eliminate a lot of the inaccuracy.

Drive in a square using a Gyroscope.

Using the Gyroscope as a Motion Detector.

This worked by measuring the rate of movement on the gyroscope, if the rate exceeded a certain amount then an alarm was sounded.

Voting Machine

We developed a voting machine, which allowed the user to vote choose between  2 options. This worked by clicking on a corresponding button for each option that was available. The value for each option was then incremented and displayed. This could be expanded to a maximum of 13 options(with lots of trickery). Most kids could manage to expland it to 5 options.

 

 

 

 

 

Slideshow

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.

 

 

 

Slideshow

RoboArt

This week we built a simplified spirograph robot that works by attaching a pen to two levers that are moved by two motors that are moving at two different speeds and directions. You can draw an almost infinite number of patterns based on the combination of speed and direction that you use as inputs.  Here is the very basic code as well as  building instructions for the robot.

RoboArt Building Instructions

Here is a compilation of some of the art produced by the robots and kids.

 

 

Slideshow

Stopwatch

Stopwatch

This week we kicked the term of by programming a stopwatch. So no building the first week, which invariably dissapoints some of the more building orientated kids. Since most of the children attended last term, everyone is more or less on the same skill level.

A stopwatch can be a suprisingly difficult concept to program. There are probably  a number of different ways to solve this problem. We did it as far as possible from first principles. So you basically have a loop that counts the number of seconds that pass. That loop is then incapsulated in successive loops for minutes, hours, days etc.

This is the most basic example. It only records seconds.

Following is the most complicated one we did in class. You can expand this in both directions even further, but you will eventually run into the limitations of the processor on the finer measurements of time and you will most likely run out of battery on the larger measurements.

 

 

 

Slideshow

EtchaSketch and Speed Trap

Beginners

EtchaSketch

The students developed a little game called EtchaSketch. This involves drawing on the EV3 display by turning two dials that control the coordinates of a dot that appears on the screen. The code works by taking the number of degrees that a motor is turned and turning that into X and Y coordinates that are then used in the display block to create a drawing. The students once again learned about concepts such as sequencing, loops, condition statements as well as concepts such as X and Y coordinates.

The code.

The result. In this case the student modified the code to draw a circle instead of just a dot which had an interesting effect. Apologies for the upside down video, but it gives an idea about what is supposed to happen.

Advanced

Speed Trap

The advanced kids built a speed trap. This used two Ultrasonic sensors in order to detect when a car is in front of the sensor. It measured the time taken between the two sensors and then knowing the distance between the two sensors we calculated the speed of the car.  Speed = Distance / Time. So if the distance between the two sensors is 30 cm and it takes 2 seconds to cover that distance then the calculation is:

30cm / 2 seconds = 15 cm/seconds

Enhancements to the code that we did was to set a speed limit and to sound an alarm if the speed limit was exceeded. We also converted the cm/seconds unit into km/h.

The code. Part 1

The code. Part 2

 

The result.

 

 

 

Slideshow

Gearing and Tug of War

Gearing:  Tug of War

This week was more about mechanics than robotics. We investigated gearing and the effect this has on a robot’s speed and torque. Then we had a number of tasks to see which robot was the strongest. These include driving up an incline carrying extra weight and also a tug of war. We also investigated the importance of traction when trying to apply the extra torque through the wheels to the ground.

With enough torque and friction we managed to do this.

 

 

 

Slideshow

Counting game and virtual coin toss game

Counting game and virtual coin toss game

Beginners

Counting game

The beginners developed a little game that counted how many times they could push a button in 3 seconds. Once they programmed this and had it working they were allowed to cheat. Cheating involved  finding as many modifications as possible that could be made to the code in order for it to count faster.  This program involved concepts such as loops, variables, decisions and incrementation.

The original code looked as follows. You can ask the kids to explain to you the modifications they made in order to make it count faster. There are 6 relatively easy modifications that can be made, after that it gets a little harder.

Advanced

Virtual coin toss game.

The advanced kids developed a game that simulates a coin toss. So they could choose head and tails and the program would randomly decide whether to choose heads or tails. This program is  deceptively complicated and requires a good understanding of logic processes. It covers concepts such as variables, decision logic and random chance. Here are some code snippets. The complete  image of the code is too large to capture so I’ve included the important bits below.

Selection of Heads or Tails.

Random selection of Heads or Tails by the robot.

Logic operation to determine if the player won or lost. (This is not entirely trivial)

 

Slideshow

SumoBot Battles

SumoBot Battles

During week 4 both the advanced and beginner kids built the normal RV2 Rover or a driving robot of their own design. This was used in Sumo battles. The object of the game is similar to a Sumo wrestling match where one robot tries to push another robot out of the ring. The code involves two tasks, one is staying inside the circle by checking the surface using a colour sensor for the black line that forms the circle. The other task is detecting another robot using the ultra sonic sensor and then charging the robot and pushing it out. Some of the concepts covered is the advantages of rear wheel drive vs front wheel drive, centre of gravity, robotic designs and multi tasking in programming.

The basic code looks as follows. There are more sophisticated SumoBot programs, but this is sufficient for now.

This is  the resulting carnage and excitement when all the robots are added into the ring.

Slideshow

Line Follower and Robotic Launcher

Beginners 

The beginners kids once again used the RV2 robot but added a Colour sensor. We then used the Colour sensor to follow a line on the floor.   The line follower program is a staple of lego robotics classes and there are highly complicated versions that are more efficient than this version. We will explore those versions in future classes.

This is the basic line following code.

 

This is the result.

Advanced

The advanced kids  built a projectile launcher robot. This was programmed to shoot a projectile at a certain velocity depending on how far away the robot was.  This is the code. There is a lot going on in this. Basically I recorded a bunch of data and then took that data and fitted it to a curve in Excel and then used the resulting equation to produce the following code. It’s cool.

Video.

 

 

 

Slideshow

Use the force

Beginners

The beginners kids once again used the RV2 robot but added an Ultra Sonic sensor. We then used this to check if there is an object in front of the robot and if there is then the robot must stop. We also did a slightly more advanced version where if the object was moved closer then the robot would move backwards. Here is the code and a short video of the robot in action.

Drive until close to object code.

Drive and reverse away from object if it moves closer.

Use the force Luke.

Advanced

The advanced kids also built the RV2 robot. They programmed the robot to speed up and slow down depending on which buttons we pushed on the brick. They also expanded this code to increase and decrease  the volume of any sound that the robot was making. A further enhancement of the code was to limit the upper and lower ranges of the volume and speed of the robot.  Here is the basic example of the code involved without any of the enhancements.