Week 2 - Section 2 - Using Variables and Detecting Obstacles

Site: ΕΛ/ΛΑΚ Moodle
Course: Advanced Coding - June 2017
Book: Week 2 - Section 2 - Using Variables and Detecting Obstacles
Printed by: Guest user
Date: Friday, 1 December 2023, 8:58 PM


In the first week we will learn about the edison robot, its capabilities, sensors and communication with the software. We will also learn how to use the EdWare, the software for programming edison robots.

Chapter 5.1 - Variables

A variable is small piece of computer memory for storing data. What makes variables so useful is that this data can change while the program is running, hence the name variable.

The Edison robot has two types of variables that are called ‘bytes’ and ‘words. Byte variables can store numbers that range from 0 to 255. Word variables can store numbers that range from -32,767 to +32,767.

Variables store numbers like 10, 106, 1,482 etc. and allow a computer program to do maths, this is something that computers are very good at.

To make variables easy to use, we give them names. This helps us humans remember what type of information is stored in them. In EdWare, you can name your variables just about anything you like. You could name one ‘Fred’, but that might not be a very helpful name for remembering what type of information is stored in Fred. A better name might be ‘count’. This type of name makes it very easy to remember what the variable is used for and what type of data to find there.

To create a variable click on "Add variable" button and then name the variable with the name count. 

Now we are going to use the variable in a loop. 


Now for an exercise try to move the robot backward and forward three 2 times using a variable and a loop.

If you are not sure you can view the image here

Chapter 5.2 - Infrared obstacle detection

The Edison robot is equipped with infrared (IR) ‘vision’. IR light is not visible to the human eye, so you can’t see this light, but it allows Edison to ‘see’ in the dark.

For Edison to detect obstacles IR light is emitted forward from the left and right side of the robot. If the IR light is reflected off an obstacle such as a wall, then the reflected light is detected by Edison’s single IR detector. The IR detector is in the front centre of the robot.    

In the illustration below there is an obstacle to Edison’s left, so only IR light from the left emitter is reflected. From the received signal Edison can determine that there is an obstacle to the left, but no obstacle to the right.

Emitted IR light is shown in red and reflected IR light is shown in blue.

Chapter 5.3 - Detect obstacle and stop

Write the following program to have the Edison robot drive until it encounters an obstacle.

The red (control group) detect obstacle icon is required to turn the obstacle detection system on and starts the IR light emitters.

The dual drive speed is set to 5 to allow the robot to detect an obstacle before colliding with it. If the speed is too fast then the robot will crash into obstacles.