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.

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.


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.

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.
EdFact
Edison has three different types of memory.
- 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.
- EEPROM – Electrically Erasable Programmable Read-Only Memory is where Edison’s settings and IR remote control codes are stored and is also non-volatile memory.
- RAM – Random Access Memory is where the variables are stored. This is volatile memory and is lost if the power is turned off.