EdVenture 9 – Change is good, let’s get variable!


Edison can guard your stuff

We can use Edison’s light sensors to trigger an alarm. This could be used as a draw alarm. Place Edison running this program in a draw, then if someone opens the draw and allows light in, Edison sounds the alarm.

Before we look at writing the program you will need to understand what a ‘variable’ is and how to use it.

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.

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.

Robot variables

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

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 ‘Light_Level’. This type of name makes it very easy to remember what the variable is used for and what type of data to find there.

Now that you know about variables let’s create one in EdWare for our light alarm program. Click the ‘Add Variable’ button in the top left corner and a pop up box will appear.

add variable to robot
Create a new variable

Type in the name of your variable as ‘Light_Level’, select the variable range as +/-32767 and set the initial value to zero. Now click OK and your variable will be added to the variables table in the bottom right corner.

Now that we have our variable we can use it in our program. Write the program below.

A robot program with variables

How the program works

The first icon is an event wait icon and pauses the program here for 5 seconds [enough time to press the play button and place Edison in a draw]. Next the program enters a loop, but this time it’s not forever. Inside the loop, the sense light icon is measuring the light level from the left light sensor and putting it into our ‘Light_Level’ variable. The loop is set to end when the value in our ‘Light_Level’ variable is greater than (>) 20 [when someone opens the draw and lets light in]. When the loop is exited the program goes to another loop. This one loops forever and has a beep icon inside [raises the alarm! There has been an intruder!]. 

Just for fun

This program is just for fun and learning about electronic systems and programming. Leaving Edison in a draw switched on for more than 20 hours will significantly reduce the batteries, so unfortunately it’s actually not a practical alarm system.


Edison has three different types of memory.

  1. Flash – Your programs are stored here, and is similar to a hard drive in a computer. This is also called non-volatile memory as data is not lost when the power is turned off.
  2. EEPROMElectrically Erasable Programmable Read-Only Memory is where Edison’s settings and IR remote control codes are stored and is also non-volatile memory.
  3. RAM Random Access Memory is where the variables are stored. This is volatile memory and is lost if the power is turned off.  
  • Keep up with Edison

    Sign up for our newsletter to get all things Edison delivered straight to your inbox.

  • This field is for validation purposes and should be left unchanged.

Heads up

The Australian Federal Parliament has passed a law that extends goods and services tax (GST) to low value imports of physical goods imported by consumers from 1 July 2018.

This means that all customers purchasing Edison robots and accessories with an Australian shipping address must now pay GST. The GST will be automatically added to your purchase and show as a line item on your invoice.

We've detected that you are in Australia, so we wanted to let you know that we have changed your settings to view our Australian site, which displays GST inclusive pricing.

You can change back to the GLOBAL SITE at any time using the link in the top left of the page.

OK got it!    Take me to the GLOBAL SITE instead

Pin It on Pinterest

Share This