FUZE Project Workbook
FUZE Project Workbook
FUZE Project Workbook
Learn to program
Discover electronics Project workbook
Debug and fix your code for FUZE BASIC
Explore robotics
Written by Jon Silvera
Prepare for your future & Colin Bodley
About the FUZE
The FUZE started out as a personal project
intended to teach my own children how
computing looked back in my day… the 1980s.
Jon Silvera
Founder
Published in the United Kingdom in 2015. ©2013/2016 FUZE, FUZE BASIC, FUZE
BASIC Project Cards and the FUZE logo are copyright FUZE Technologies Ltd. This
document may be copied and distributed for use within educational establishments,
however it may not be edited, modified or sold in any format or by any method without
written approval from FUZE Technologies Ltd. For more information about FUZE
fuze.co.uk BASIC Project Cards and The FUZE visit www.fuze.co.uk.
Index
Page 4: Getting Started
“Lighting the FUZE”
Setting up the FUZE computer system Connecting, switching on and loading the
What is a computer? operating system. Selecting and executing
Computer basics applications.
About computer memory
A simple introduction to computer memory
and how information is digitally stored both in
RAM and storage memory.
FUZE IO board
The FUZE IO board
is where you connect the
FUZE to the real world.
Flashing lights, sensors, robotics and
much, much more await…
FUZE mouse & mat
The FUZE mouse needs to be plugged in to
one of the USB ports on the back of the FUZE.
Motherboard
The computer inside the FUZE. This little board contains the CPU
(Central Processing Unit), RAM (Random Access Memory), storage
memory, USB sockets and a whole lot more, which we will look at later.
A bread board….. excuse me, did I
hear you correctly?
Electronic components kit This is used to build simple
The project kit includes 24 x coloured LEDs, 1 x seven segment LED, electronic circuits. In the olden days,
1 x light dependent resistor, 8 x micro switches, 30 x resistors actual wooden bread boards were
(mixed specifications), 20 x Jumper cables and 60 x Jumper wires. often used for building prototype
circuits and the name just stuck.
5
Setting up your FUZE GET WITH THE PROGRAM
Connect a display, the power supply and mouse then, if it is not already Getting started
in, insert the SD Card (face down & carefully). Ensure the display is on
and then switch on the FUZE. Often, in schools, the Raspberry Pi is re- “Lighting the FUZE”
cessed a little to block easy access to the SD card. To access it remove
the top two screws to lift the lid.
Audio Jack
Only power on the system after you have inserted
If you’re not using a HDMI display with built in speakers
the SD Card. The system will not boot otherwise. then you can connect separate speakers to this socket.
You need to run the Raspberry Pi config program to tell
Power Socket the FUZE to send audio out via this socket.
Plug the FUZE power supply to the wall socket
and then the small end into the FUZE here.
Please make sure the FUZE
power switch is off when HDMI Display
connecting. Connect your HDMI
TV or monitor here.
If you have an older
On / Off switch VGA or DVI display
It’s best to shutdown the you will need an
operating system from the adapter (available
Desktop before switching from the FUZE
off. Only switch off once the website).
small red light on the FUZE IO
board has gone out. SD / MicroSD slot
This slot is where you insert the FUZE
SD card. This is the equivalent to a
Four available USB ports Internet / Network socket computer’s hard disk and as such
Connect various USB devices to these ports including To connect to the Internet or a network should be handled with care. Do not
your wireless mouse dongle (supplied) and robot arm via a hub connect the network cable remove or insert unless the red light
kit (optional). You can connect USB flash drives to here. Otherwise you can plug a Wi-Fi on the FUZE IO board is off.
easily transfer programs and information. dongle into a USB port.
6
Everything you were afraid to know about computers but had to ask! GET WITH THE PROGRAM
Before we dive into the main projects why not take in a page of useless Getting started
really useful information…
“Lighting the FUZE”
So what is a computer? “That’s easy” I hear you say, “a computer is a
magic box that makes our world better because it has games, the Internet,
YouTube and Google”. Well yes, but how on earth does it do these things, Humans also have two kinds of memory - internal and
what’s going on inside the magic box? external. Internal is what we use all of the time to
remember and store information. External can be
I’ll try and make this quick… compared with encyclopaedias, dictionaries, the Internet,
A computer is an electronically powered calculating machine. Even an phones, books, invoices, comics, story books,
iPad / phone / Playstation / XBOX / Nintendo etc., are all just overgrown documentaries, films, photos and even music notation.
calculators. Although another way of looking at it would be to say a
computer is an electronic human… don’t believe me?, read on… Next up are the input and output devices. Humans have
senses like sight, hearing, touch, taste and nerves for heat
A computer has a number of main parts which allow us to make use of
or pain. Computers have keyboards, mice, touch screens,
them. It’s hard to list this in an order of importance as each part is pretty
monitors, cameras and electronic sensors for heat, light,
much as important as the rest but here goes;
motion, location and so on.
The CPU or Central Processing Unit. It is easiest to think of this as a
computer’s brain. In fact it works in very similar ways to our own brain. The difference between computers and humans today
Memory, again similar to humans, is used to store information, and in is intelligence. Whereas we humans have had a few
computer terms, everything is stored in memory. The picture on an iPad hundred thousand years to evolve our ‘programs’,
screen, the sound from a film, the music you download, every single computers have only just arrived. By comparison their
YouTube video, the key presses you type in an email or search engine, the ‘programs’ are just being born and they are evolving
movements from a mouse or on a touch screen and so on, everything is very quickly or at least, we are evolving them.
stored in computer memory.
Computers have two kinds of memory, quick access, which is available Lastly, a computer needs a source of power like a
only when it has power (or is alive!) and storage memory which is battery or a plug in a wall socket. Computers cannot
recorded to a permanent storage device like a hard drive, a DVD / Blue- convert food into energy just yet!
Ray disc, USB flash drive or as is popular nowadays, in the Cloud!
7
Yes but how do they actually work? GET WITH THE PROGRAM
Let’s go back to the brain, sorry, the computer’s CPU. The CPU is quite simply,
Getting started
millions of tiny switches called transistors and logic gates. Depending how they
are set up the computer can be programmed to do different things. Information “Lighting the FUZE”
is sent to the CPU, then the CPU performs an operation on that information and
then sends the result to whereever it needs to go. So our new image would now look
Imagine a picture made from a grid ten little dots long like this;
by ten tall. Each dot can be any colour. With only a 10 x With only ten by ten pixels we
10 grid we couldn’t draw anything detailed but it can can’t do anything serious but I’d
give us an idea. like to try and get things in context
Now imagine that the very bottom left hand corner is so bear with me…
position number one and the very top right hand corner
is position one hundred. This gives us 100 memory To make each pixel a different colour takes a single
locations we can store information. unit of memory and each unit of memory (known as a
BYTE) can only hold a number up to 255 (actually 256
If we use these memory locations for our display then we can control what is
but computers always start from zero). So this means a
displayed just by changing the values of each location.
picture can only have 256 different colours right… no,
For example if dark red has a value of 10 and bright red is 100 then we could wrong!
increase the brightness of all the dark red pixels in our image just by adding 90 What if we joined more units (Bytes) together, in fact
to them. To do this a program is required. The program is also stored in how about we use three bytes for every pixel.
memory somewhere and could look something like this;
Light behaves differently to paint in that we use
Memory = 1 // Setup our memory counter to start at position 1 Red, Green and Blue light to make up any colour.
LOOP UNTIL Memory > 100 // Starts a loop that will stop at 100 Computers use each byte to store a maximum of
Value = PEEK Memory // reads a memory location and saves it in the variable Value 256 shades of each colour component, so the first
IF Value = 10 THEN Value = Value + 90 // if it is dark red add 90 byte is a shade of red, the second is green and the
POKE Memory, Value // write the new value back to memory third is blue. This means each pixel is made up
Memory = Memory + 1 // increase the Memory counter from three bytes each with a maximum of 256
REPEAT // go back to the start of the loop shades of R, G or B.
8
How many colours per pixel do we have now? well the GET WITH THE PROGRAM
sum is 256 x 256 x 256 = 16,777,216. 16 million colours
for each and every pixel.
Getting started
The picture on the right is just 20 pixels wide by 30 tall.
“Lighting the FUZE”
Even with such a small picture it starts to look like a
photograph. Memory is still expensive, although not like it was early on.
Ok but what’s this got to do with computer memory? However we would need tons of the stuff if computers
today stored all our photos, movies, music and of course
Well this picture is 20 pixels wide x 30 pixels tall and each pixel is using homework in their main memory.
three bytes of memory. To store this image therefore takes 20 x 30 x 3 bytes
of memory. That’s 1,800 bytes to store this tiny little image. This is why computers also need storage memory and why
we talk about hard disks. We use hard disks to store
In the early days of computing memory was incredibly expensive to make
information so it can be accessed whenever we need it.
so computers came with very small amounts of it.
A computer’s main memory is called RAM, short for
The very first home computers shipped with as little as 1K of memory, that’s Random Access Memory. This is the computer’s
1,000 bytes. Actually it is 1,024 bytes because computers don’t generally working memory and, just like your brain, if you
think in decimal or base 10 as it is known, they think in base 2, or binary. switch it off, the information it has within is lost
More on that later. The K in this case means kilo or kilobyte.
forever. Very sad indeed.
1 kilobyte requires 1,024 memory locations, 1 megabyte is 1,024 x 1024
Storage memory is therefore just as important as
bytes or 1 million memory locations and a gigabyte is 1024 megabytes, a
RAM as it allows us to keep information forever.
terabyte and then a petabyte follow.
When we talk about Cloud storage it couldn’t
Early computers could not have even displayed the above image let alone
actually be further from the truth. Cloud storage is
store it in their tiny memory. Computers in the nineteen eighties were very
quite simply very powerful computers with gigantic
limited indeed.
amounts of storage memory, connected to the
A modern digital camera today can take pictures with a pixel resolution as Internet. They are often stored underground to
high as 5,000 x 5,000. Work out how many bytes that needs; keep them protected. Hmm, the Cloud eh…!
Remember, 5,000 x 5,000 x 3 (for the pixel colour), that’s around 73 We’ll come back to how computers work later on,
megabytes of memory for a single picture! for now let’s get programming…
* Do you recognise the incredibly famous handsome man in the picture? Whad’ya mean “no”…. It’s me you fool, me! You’ll get marks deducted for that, you’ll see, they’ll all see..
9
GET WITH THE PROGRAM
Commands introduced
LOOP, REPEAT, INK, PAPER, WAIT()
and PRINT
You will get an error as shown in [Pic 2]. This is because there’s no PROGRAM in Learning to program is like learning to control the world…
the computer’s memory. Don’t worry, it’s nothing serious, as you will soon see. Mwaaah hahaahaha!
* This of course is completely untrue.
11
Press F2 *. Now we’re getting somewhere [Pic 3]. This is the GET WITH THE PROGRAM
Program Editor. It allows us to enter and edit programs. If there Project Stage 1-1
is already a program there press the F12 key. This will erase any
previous program. Now, using the editor, type in;
“Hello World!”
Editor * F1, F2, F3 The Function keys
Across the top of your keyboard you
Cycle
will find a line of keys beginning with
Print “Hello World” an F and numbered from 1 to 12.
Repeat These are called the Function keys.
They can be programmed to do
Before we RUN * this program we should save our work. See the specific things. Press F1 in the FUZE
IMPORTANT note on the right of this page. BASIC to access the Help system.
[ Pic 3 ]
Let’s take a closer look to see if we can work out what our program is
going to do. Take each line, one-at-a-time; * RUN The RUN command
simply tells the computer to
Cycle - Hmm.. That’s not much to go on - try the next line; execute or start the program that
is in memory. When you turn on
Print “Hello World” an iPad for example, the device
RUNs the software to make it do
This one makes more sense. It’s going to print the words “Hello World”, all of those lovely things we take
but wait, we don’t have a printer! That’s Ok because Print in this case for granted.
means, print to the screen display.
SAVE - IMPORTANT - SAVE
And so to the last line; Repeat It’s very important to save our work, as when a computer is
shut down, any unsaved work is lost! To save, press F5
What does it all mean? Well, the first line of our program says Cycle and when in the editor (or F3 to save & RUN). Delete any
the last line says Repeat. The Cycle statement tells the program this previous filename and then enter your own, for example,
“Taylor” (without the quotations) and then press Enter. It is
is the beginning of a loop. The Repeat statement says go back to the
best to avoid using any special characters in file names, so
Cycle statement and ‘repeat‘ anything in between. stick to letters and numbers to be on the safe side.
Keep going, we’re on the right track
12
What do you think will happen when we RUN the program? GET WITH THE PROGRAM
Take a little pause to think about it . . . . . . Let’s try it and see if you
Project Stage 1-1
were right. Press F3 to RUN the program. “Hello World!”
Whoa! How do we stop it? [Pic 4] Press the Esc key. This will stop Memory
the program from running. In future we will say press Esc or even A computer generally has
just exit the program. [Pic 5] two types of memory. The
first is its working memory
Press F2 to return to the program editor. where it keeps everything
running when it is switched
So what happened? The last line, Repeat, tells the computer to go on. The second is where
everything is stored when it
back to the first line, Cycle. is turned off.
[ Pic 4]
So repeat it did, and then it Printed “Hello World” again, then to the
If you switch a computer
Repeat statement again, and so it did, back to Cycle, Print “Hello off, then everything in the
World” and Repeat again, and so it did, back to…. Ok, I think you get working memory is lost.
the idea! We save or store
programs in storage
Let’s try something else. In the Editor, move the cursor (the white memory so we can use
square in the editor) to just after the last ” and add a semi colon ; them whenever we want
without having to type
[ Pic 5 ] them in all over again.
Editor
Note: To RUN the program within the Editor press F3. To
Exit the Editor press the Esc or F2 key. You can then RUN a
Cycle program by typing in RUN and pressing Enter. The Editor
Print “Hello World”; has its own set of keyboard commands that we will learn
Repeat about later. If you are not in the Editor for any reason then
on the main screen press F2 key to get back to it.
Then move the cursor to the end of the same line and press Enter.
[ Pic 6 ]
This will insert a new line. Now add a new command; Wait(1). So
now you should have;
Editor
Cycle
Print “Hello World ”;
Wait(1)
Repeat
[ Pic 7 ]
Press F3 to exit and RUN the program. If everything’s gone to plan As you can see here, even missing out a single space in
our program makes a difference. The computer doesn’t
then your program should display “Hello World” at a nice steady pace
understand we have spaces between words so we have to
and should have spaces in all the right places. program them in.
I wish I was a Viking, strong bold and striking…
14
Ok we have some explaining to do. We added a new command, GET WITH THE PROGRAM
Wait(1). Wait(1) is actually pretty straightforward, Project Stage 1-1
especially if you watch the program running.
“Hello World!”
Wait(1) tells the computer to wait for a specified time. In this Computing and colour
Computers usually work with just three different colours, Red, Green
case, for 1 second. If you wanted to use less than a second you
and Blue or RGB. Each colour has 256 shades from very dark to very
need to specify a number with a decimal point so 0.5 is half a light. By mixing these a total of 16,777,216 (256 x 256 x 256) colours
second or 0.1, a tenth of a second. can be displayed which is lucky as this is about as many as the
human eye can manage!
It’s time to brighten things up a bit. All this black and white text is
And another thing, computers do not mix colours like paint. Computers display
really dull, don’t you think?
colour with light. Mixing light gives different colours to mixing paint. For example,
blue light and green light makes cyan, red light and green light makes yellow.
Pick a colour, any colour…. Actually not any colour, pick one of Red, green and blue light makes white or grey if you only use a bit of each.
these [Pic 8];
[ Pic 8
However, please do not pick black or else we’ll end up in no-end
of trouble, as black text on a black screen makes things a bit
difficult to read!
Ink=Red
Press F3 to RUN the program. Isn’t that pretty… Paper=White
CLS
Press Esc to exit the program and Esc again. We don’t want to go
back to the Editor this time as we are going to enter a few commands Wow!
directly.
If you get stuck,
use CLS to clear
Now we have a new problem. Everything’s gone green. Well
the screen and
everything’s changed to the colour you picked. This might be Ok, but then enter;
if you chose something very bright or very dark then it will make it
hard to read and edit the program. Before we go back to the editor Paper=black
Ink=white
type in Ink=white and press Enter. This will set the colour to white CLS
again.
This will return us
Ink in FUZE BASIC sets the text colour, and Paper sets the to the normal
background colour. settings. Phew!
You can try this out before going back to the editor. Set the colours to
something you like! [Pic 9]. [ Pic 9 ]
Cycle
Ink=Pink
Paper=Blue
Print “Hello World ”;
Wait(1)
Repeat
Press Esc to exit the program, F2 to return to the editor and then try a
few different combinations. You’ll also see that the colour settings are Programming is for boys, not girls…
now the same for the Editor. RUBBISH! Did you know the first ever actual computer
program was written by a young lady called Ada Lovelace.
Ada is famous for inventing computer programming and
IMPORTANT there is even a programming language named after her,
Finally for this project you need to SAVE your program. If we don’t “ADA”. Ada worked with another very important inventor,
SAVE it then when you switch off the computer the program is lost Charles Babbage who invented the first ever
forever. Press F5 to save the program. programmable computer called the Analytical Engine - you
can see why they got on so well!
Assessment 2
How could you make the program go really fast or really, really
slowly? What was the command now… let’s just Wait a moment
and think about it! Nice colours
Anything you like, anything,
go on, pick a colour.
Assessment 3
What about different colours? Try and make the program display
different colours. Hmm. “Ink=”
Assessment 4
Ok this one is a bit harder. Could you add another line of code to
display (Print) some more text, “My name is Pi” for example.
What about in another colour too and hey, while you’re at it, add Way to go!
another Wait to keep it all running smoothly!
variable Apples, it knows to print 6 as this is the value we gave to the So, what programming language do you think it came
variable in the line above. with?
BASIC, that’s what, good old BASIC. While the language
Because the last word, “ Apples” is in quotation marks, the computer has come on a long way since the early versions, you’d be
does not see this as a variable, it is just text it must display. amazed just how similar FUZE BASIC is today.
And another pointless comment…
22
Hmm.. All these apples are making me hungry! Edit your code to; GET WITH THE PROGRAM
Editor press F2 to display the edi- Project Stage 1-2
tor
[ Pic 4 ]
“Variables eh?”
CLS
Apples=6
Memory
Print “We have ”; Apples; “ Apples” Computers are all about
Print memory. In fact without memory
Print “If we eat one…” a computer would not really be a
Print proper computer at all.
Apples = Apples - 1
Wait(2)
When a program is running it’s stored in the computer’s working
Print “then we have ”; Apples; “ left.”
memory (RAM - Random Access Memory). If the power is
END switched off everything in RAM is lost. To avoid this we use
storage memory to save our work. This could be on a hard disk,
The extra Print command after each Print line displays a blank line to
Solid-state drive, memory card or a USB drive These kinds of
keeps things tidy. memory devices store information permanently without the need
for power. Storage memory is much slower than RAM so we use
Apples=Apples-1 instructs the computer to reduce the value of both, otherwise computers would be very, very slow.
Apples by one and store the answer back in the variable Apples.
CPU - You have to love computing and all its acronyms. An
We have used a Wait(2) command to tell the computer to wait for two acronym is a word made up of the first letters of a sentence
or phrase. We use them to shorten a long phrase into a
seconds. Well, we need time to eat it!
short one. For example “PE” is short for Physical Education
and “PSHE” for Personal, Social and Health Education.
Finally we Print the result. This time the value of Apples will be
different. RUN (F3) your program to see what happens [Pic 4]. It’s a bit like TXT speak really… LOL!
Still hungry huh? Well hold on to your seats, I can feel one of those So back to the CPU then. The Central Processing Unit is
quite simply, the brain of any computer. It’s the boss - it
LOOP things coming on. Return to the Editor, unless you’re already
keeps everything under control. A bit like a Head Teacher,
there, by pressing F2, and edit your program to the following; but it doesn’t moan all the time!
And another pointless comment…
23
Editor GET WITH THE PROGRAM
Apples=6 Project Stage 1-2
Cycle “Variables eh?”
CLS P.I.C.N.I.C.
Problem In Chair, Not In Computer.
Print “We have ”; Apples; “ Apples”
Don’t forget, a computer will only
Print do exactly what it is told to do,
Wait(1) nothing more, nothing less. Because
Print “If we eat one…” a variable is just a name we can
Print store numbers in, it matters not if
Apples = Apples - 1 that number is large, small, positive
Wait(2) (+) or negative (-).
[ Pic 5]
Print “then we have ” ;Apples; “left.” If we tell a computer to count down
Wait(2) in one’s from 50 a hundred times, it
Repeat will do exactly that. It won’t stop at
END zero, it will just carry on until it gets
to minus (-) 50 [Pic 6].
Before we run the program let’s take a quick look to see what’s going
to happen. [ Pic 6 ]
It’s logical
Computers are all about logic. There are no grey areas. No
Remember the Cycle & Repeat commands from the last stage? maybe, perhaps or possibly. Either something is or it is not.
Everything between these two lines will be repeated so when it gets to
That’s not to say we can’t program a computer to behave
the Repeat command it jumps back to Cycle, clears the screen (CLS)
illogically. In fact, it’s possible to write programs that can
and does it all again. Each time the value stored in the variable, appear human. There are even competitions to see who can
Apples, is reduced by one. write a program to fool a human being (that’s one of us), into
thinking a computer is actually another human. I recommend
RUN (F3) the program [Pic 5]. What happens when we get to zero researching ‘The Turing Test’. We’ll come back to Turing, or
Mr Alan Turing to you and me, a bit later as he was a very
Apples? We can fix that. Exit the program (Esc) and press F2 to return important chap indeed. I say ‘was’ because he’s been dead
to the editor. for more than half a century, which is a shame!
And another pointless comment…
24
Editor GET WITH THE PROGRAM
Apples=6 Project Stage 1-2
Cycle
CLS
“Variables eh?”
Print “We have ”; Apples; “ Apples” LOOP the LOOP
Print Most computer programs do similar things over and over again so
Wait(1) understanding Loops is going to be very important. Consider
Print “If we eat one…” games for example. A game needs to check to see if you’re
Print pressing a key or moving a joystick. Even when you move a mouse
Apples = Apples - 1 around the screen or touch a screen to zoom a photo. The entire
time, the computer is running in a loop checking the mouse for
Wait(2)
movement, the screen for touch and the keyboard for key presses.
Print “then we have “; Apples; ” left.”
Wait(2) Loops are another very important part of any computer program
Repeat Until Apples = 0 so once again… PAY ATTENTION!
CLS
Ink=Red In our Apple program we’ve
Print “We ran out of Apples!” used a specific kind of loop
called ‘Repeat Until’
Print
Ink=White
END
Take a look at the Repeat command. We’ve added an Until condition to it. [ Pic 7 ]
This says keep repeating the program Until the value of Apples is equal to
zero. So every time the program arrives at this command it checks to see if
Apples=0 and if not it goes back and does it again. If it is zero then it goes
on to the next line and carries on with the program.
The beginning of the Loop starts with the Cycle
command. Everything in between ‘Cycle’ and ‘Repeat
When Apples gets to zero we clear the screen (CLS), change the text colour
Until’ is repeated until the ‘Until’ condition is met. So the
and Print a new message, and just to keep things tidy Print a blank line and program will ony continue past this line when Apples=0
change the text colour back to white ready to edit. otherwise it jumps back to the original Cycle command.
See!
25
Before we end this stage we’re going to look at how we enter our GET WITH THE PROGRAM
programs, because as they get bigger and more complicated they Project Stage 1-2
can start to look messy and become difficult to understand.
“Variables eh?”
So far, we haven’t worried about general formatting but from now More about Memory, CPU’s and Loops
on we will! The memory in a computer stores all the information a program
You don’t need to enter the program below (you can if you like needs to work. Imagine computer memory being like a ladder, a
really, really tall ladder indeed. Each foot hole is like one unit of
but remember to save your current work first). A quick glance and memory that can contain a single number.
you can see how much easier it is to read. If we store 10 numbers in memory and want to add 5 to each
Editor - Example - you do not have to type this in one, then firstly we need a Loop to count from 1 to 10. The CPU
has to go to the first memory unit, copy the number to a
CLS temporary location, add 5 to it and then copy the result back into
CYCLE the first memory unit. The loop goes back to the beginning but
INK=Red this time works on the second memory location and so on, until it
PRINT “My name is Raspbery Pi” has completed the entire block of ten memory locations.
PRINT A photograph is stored in memory as a series of numbers. A high
WAIT(1) quality picture needs millions of memory units. To make the
INK=White picture brighter we have to change every single number. This
PRINT “I live in this FUZE computer” means the computer has to do millions of simple sums just to
REPEAT increase the brightness of a picture.
END Luckily CPU’s are very fast. In fact most modern computers
have more than one CPU. You’ll read about computers with
All commands are now in capitals so we can see instantly what is a
Dual Core (2 CPU’s), Quad Core (4), Oct Core (8) and higher -
command and what is a variable. basically, the more Cores, the more powerful and the more
things it can do in a ‘clock cycle’.
More important though is the use of indentation (nudged over!). Every
time we use a LOOP the lines in the middle are indented. This makes CPU speed is measured in Hertz (Hz), or at least it used to be.
Today we measure in Mega Hertz (Mhz) and Giga Herts (Ghz).
everything much neater. Sorry to go on about it, but you’ll find out later
One Hz is one clock cycle per second. At one Hz the
it’s very important indeed - not like making your bed or getting to brightness calculation above would take weeks to finish. With
school on time, no, this stuff really matters! Ghz CPU’s the same process can be done millions of times
Just a couple more and I’ll have this one in the bag!
26
Stage 1-2 Assessments GET WITH THE PROGRAM
So, you think you’ve grasped variables eh? Just you wait, Project Stage 1-2
you’ve seen nothing yet! For now though… “Variables eh?”
Assessment 1
Can you change the program so that it’s all about a different item
Apples are not the only
of fruit. Don’t forget to change all the variables and all the times fruit!
we mention apples. Remember to change
‘Apples’ in every instance.
Assessment 2
Can you change how many we eat at a time. Remember to change
the text saying “if we eat one…”, as well as the sum using the
variable Apples, or whatever you changed it to above.
Make it pretty!
While you’re at it why
Assessment 3 not liven things up
with a bit of colour.
How about starting with a higher or lower number of items at the
beginning.
Assessment 4
Finally, try this; Start with 10 Cakes. Count down 2 at a time and Now that’s
when you are down to 4 left change it to say, “I’m bored of cakes… impressive
can I have an apple?!” Ok, if you’ve
managed to do this
part you’re doing
End of Stage 1-2 really well.
double click the FUZE BASIC icon. When you see the Ready >
prompt we can begin.
Now you should see Bilbo Potter which looks much better but still, Using the telephone was a very different experience than it is
it’s not quite right is it? Perhaps you should add another variable; today. Most households had just one phone so if you wanted a
private conversation, off you’d go, rain or shine down the road to
Name4$=”Baggins” the nearest phone box (a big red cubicle in the middle of the
street!). Sometimes you would have to queue and if the person
This should sort things out, type in; you wanted to speak to wasn’t in, you couldn’t leave a message.
You even had to insert coins before it would work!
Name3$=Name1$+“ ”+Name4$ - press Enter
Print Name3$ - press Enter Today we can text a friend in seconds, email letters, memos
and pictures anywhere in the world and look up information
Bilbo Baggins on the Internet about anything you can imagine.
There, that should keep everyone happy, especially Tolkien! More than this though, it was not that long ago you would
need a different device to do any of these things - now we
So text variables ($) can be treated in a similar way to number ones. just pick up our phone or tablet and do everything from there
We can add bits, take bits away, search for information in a $ and including take photos, listen to music and watch films.
even convert them into numbers.
It’s very likely, with recent developments, that in the next few
years all of the above is going to be on your wrist, straight
Time to begin a new program!
from your watch and a pair of snazzy glasses!
This is incredible considering there are only 7.1 billion people in the world today
30
Press F2 to enter the Editor. If there’s another program listed GET WITH THE PROGRAM
then make sure it isn’t needed and then press the NEW icon to Project Stage 1-3
clear it.
“It’s String Theory - knot!”
[ Pic 3 ]
Editor
CLS
INPUT “Hi, what is your name? ”, name$
WAIT (1)
CLS
PRINT “Hello ”; name$
END
CLS clears the screen and sets the background with the current
PAPER colour, which if it has not been set, is always Black.
INPUT is used when information needs to be entered into a
program. In fact, one way or another the INPUT command,
The WAIT (1) command tells the computer to wait for one second.
or variations of it, are used every time you enter your name
We can change the length of time by setting the number higher or and email address on a web page, every time a PIN number
lower. 1 is one second, 0.5 or .5 is half a second and 0.1 is one tenth is entered in a cash machine and even, every time a number
of a second and so on. The END statement indicates the end of the is tapped into a phone. It is therefore worth spending
some time getting to know it.
program.
We can use INPUT to request numbers or text. The
So, on with the program. We’ve introduced a new command, INPUT. variable name at the end of the INPUT statement should
When used like this the computer will display the text in quotes (“”) have a $ symbol to indicate it is a text variable. This is not
and then wait for the User to ‘Input’ something. Whatever is typed in required for a numerical one.
is then stored in the variable, name$ name$ = 10 - will give an error
name = “Taylor” - will give an error
RUN (F3) and enter your name when asked then press Enter [Pic 3]
and only 30% of the world’s population is actually connected to the Internet
31
It really doesn’t matter what you type in as it will still be stored in GET WITH THE PROGRAM
the variable name$. Now let’s add another variable and see what Project Stage 1-3
else we can do. Edit your code as follows;
“It’s String Theory - knot!”
Editor press F2 to display the editor [ Pic 4 ]
CLS
INPUT “Hi, what is your name? ”, name$
PRINT
INPUT “What is your favourite hobby? ”, hobby$
PRINT
WAIT (1)
CLS
PRINT “Hello ”; name$
PRINT
WAIT (1)
PRINT “So you like ”; hobby$; “ eh!”
END
We have a new question about hobbies and a new variable. The result
is stored in hobby$ and can now be used at any time just by referring
to the variable name. Notice on the last PRINT line we’ve inserted the
variable hobby$ right into the middle of a sentence. Of course it
won’t display “hobby$” as it knows to display whatever is stored in There are many commands related to INPUT that will help you to
the variable instead. This helps us to make the program seem more enhance your programs. Most of these allow the computer to
friendly and personal. understand what has been entered so you can program it to
respond accordingly using IF THEN commands.
Let’s find out a bit more about our user shall we? First though, now
One of the main computer uses over the last seventy years or so, has
would be a good time to save our work - When in the Editor press F5 been to store information about people so it can then be found
to save your program. Then edit the program as shown overleaf. quickly by hospitals, banks, insurance companies and the police.
This means on average, there are five devices connected to the Internet per person
32
Editor GET WITH THE PROGRAM
CLS Project Stage 1-3
INPUT “Hi, what is your name? ”, name$ “It’s String Theory - knot!”
PRINT The Database
INPUT “What is your favourite hobby? ”, hobby$
A database is quite simply a list, often a very large list, of information
PRINT
stored on a computer. A simple database can look like the following:
WAIT (1)
CLS Pet Monster Database
PRINT “Hello ”; name$ Record 1:
PRINT [Field 1] Pet Name: Tyrannosaurus Rex
WAIT (1) [Field 2] Size (lrg-med-sml): lrg
[Field 3] Cuteness (1 to 10): 3
PRINT “So you like ”; hobby$; “ eh!”
[Field 4] Attack power (1 to 100): 95
PRINT [Field 5] Health (100 to 1000): 800
WAIT (2) [Field 6] Speed (1 to 100): 20
INPUT “How old are you? ”, age
Record 2:
PRINT [Field 1] Pet Name: Fluffy the Rabbit
PRINT “I see…” [Field 2] Size (lrg-med-sml): sml
PRINT [Field 3] Cuteness (1 to 10): 10
WAIT (2) [Field 4] Attack power (1 to 100): 10
[Field 5] Health (100 to 1000): 100
IF age < 10 THEN PRINT ”Wow, so young, you’re lucky!”
[Field 6] Speed (1 to 100): 95
IF age >= 20 THEN PRINT ”that’s really, really old!”
PRINT Once the information has been entered we can write a
END program to perform different tasks depending on what we
want to do. Say for example we wanted to make a card game,
RUN (F3) the program. Clever eh! Run it again so you can enter ages we could use the DATA (the name given to information
younger than 10 and older than 20. stored in a database) to work out who was the strongest or
fastest and therefore was most likely to win in a battle or win
We’ve added a new variable, “age” to store the value the user enters and a race or even a beauty contest.
then the two “IF THEN” statements give different results depending on I think it’s safe to say that the humble database is very likely
the user’s input. Complete the program overleaf… to be the most common type of program ever.
In this case the first condition is; “IF age < 10” or “if age is less “01000001” So obvious you say, well yes, quite!
than 10” then print the “so young” message. The next line checks Ok, here’s how it works; each digit from right to left has a value.
the condition “IF age >= 20” or “if age is more than or the same The first is 1, the second is 2, and then 4, 8, 16, 32, 64 and 128.
as 20” then print the “old” message. “>=” and “<=” are known as
“more than or equal to” and “less than or equal to” Each individual binary digit is call a ‘BIT’, eight in succession are
called a ‘BYTE’, 16 of them a ‘WORD’, 32 a ‘LONG WORD’. We
IF THEN conditional statements are used a great deal in only need to worry about BITS & BYTES though (phew!)
programming. We will be exploring them a lot more later.
So, ‘01000001’ = 65 128 64 32 16 8 4 2 1
The last part of our program asks the user, by name (with name$ because;
0 1 0 0 0 0 0 1
added to the end of the line) for their favourite colour and
depending on the answer given, then displays different messages. We simply add the BITS that are on ‘1’, together to give us
The user’s favourite colour is stored in the text variable col$. our actual number, 65 in this case, and then the computer’s
Operating System works out the rest. So if it is expecting text
We’ve also introduced another variation of the “IF THEN” it knows that 65 equals the letter ‘A’ and so it displays an ‘A’.
conditional statement. This time we’ve used IF col$ <> “pink” and
IF col$ = “pink”. “ <> “ means “is not the same as or not equal Do you know what 128 64 32 16 8 4 2 1
to” and “ = “ means “is the same as or is equal to”. this Binary number
represents? 1 1 1 1 1 1 1 1
Ok, that’s all for now - please try the assessments overleaf.
We will come back to Storage and Memory in a later project.
Perhaps the more astonishing fact is not how many people are connected…
35
Stage 1-3 Assessments GET WITH THE PROGRAM
Right then, now that you’ve mastered String Theory, er.. not Project Stage 1-3
quite!, see how you get on with these;
“It’s String Theory - knot!”
Need INPUT
Turn your computer
Assessment 1
into a friend for life…
Could you ask another question after the Hobby one? What about so you’ll always have
“Favourite food” using food$ as the variable name. You should also someone to talk to!
add something like PRINT “You like to eat “; food$ too.
Assessment 2
Using “IF age = “, add one or two new responses to the “How old are
you?” question. If you check, you will see that nothing currently
How old?
happens if you enter numbers between 10 and 20…
You know it’s rude to ask
old people their age so
Assessment 3 don’t ask a teacher!
Can you change the colour section so that it will respond with
different answers to more colours. You should remove the line with
IF col$ <> “pink” for the moment as this will confuse things.
Did you get this far? You deserve a pat on the back!
but that FIVE BILLION people are not!
36
GET WITH THE PROGRAM
128 64 32 16 8 4 2 1 Using the same numbering system you will find a 32 BIT
0 1 0 0 0 0 0 1
= 65 number goes up to about 4 billion and 64 BITs, well just rest
assured it’s huge!
Each binary digit in sequence represents a value. The sequence above is an As time goes by computers become faster and faster. Not
8 BIT number or a BYTE. If all the BITs were on, or 1s, and you add them all just because the number of BITs increases but the speed
together you have a decimal value of 255. 1+2+4+8+16+32+64+128 = information moves around the computer increases and the
255. There’s still one more value though and that’s if all the BITs are off or number of calculations a computer can do in a single second
zero. This is the same as the decimal value 0. This gives us 256 possible also improves every year or so. We measure computer
values for an 8 BIT number. So what does a 16 BIT number look like… speed in MIPS or Million Instructions Per Second.
Many scientists and electronic engineers believe the transistor is the most 0 1 0 0 0 0 1 0 = 66
important development in the history of computing. Without it the
iPhone, Samsung Galaxy, PS4, Nintendo 3DS and just about any other 0 0 1 0 0 1 0 0 = 36
computing device you’ve ever heard of may well not exist today. Or at 0 1 1 1 1 1 1 0 = 126
least if they did they’d not be as small or as fast!
0 1 0 1 1 0 1 0 = 90
Everything a computer does is an interpretation of the state of these
transistors. If they are on they have a value of 1 and if they are off then 0. 1 1 1 1 1 1 1 1 = 255
Using the binary system these can be converted into decimal numbers 1 0 1 1 1 1 0 1 = 189
which in turn can be turned into characters, graphics and sounds.
1 0 0 0 0 0 0 1 = 129
Take a Space Invader… 0 1 1 0 0 1 1 0 = 102
This how it might look on screen (left) but
to the computer it is just a series of switches Now all we have to do is feed this information into the
left in an on or off position (right) computer somehow. Sounds like we’ll need some kind
of Program!
That’s all well and good but it’s difficult for us to use binary All the letters, numbers and symbols we use when
information like this. Using the binary system we can easily convert typing an email or a txt etc., are created in a similar way
this into a series of decimal numbers. Remember, the first digit from and we can in fact design our own characters using
right to left has a value of 1 then the next 2, then 4, 8, 16, 32, 64 and FUZE BASIC.
finally 128. At least that is what an 8 BIT number has. So going back
to our chart we can convert this as follows; You will however need some graph paper, a pencil and
probably a calculator but more on this in a minute…
Eight BITs in a row are known as a BYTE and 1024 BYTEs is a KILOBYTE while 1024 KILOBYTES is a MEGABYTE
39
In the FUZE BASIC editor type in the following program; GET WITH THE PROGRAM
Editor press F2 to display the editor Project stage 1-4
“It’s all 1s and 0s to me!”
CLS
This needs some explaining…
DEFCHAR (1, 0, 66, 36, 126, 90, 255, 189,129, 102, 0)
CYCLE Firstly there is a new command to take care of, DEFCHAR. This
PRINTAT (0,0); chr$(1); allows us to redefine the shape of any of the standard
REPEAT characters. The first number, in this case 1 and 2 tells the
END computer we want to redefine the first two characters available.
The next ten numbers represent each horizontal line of the
RUN, F3, this and you should see a tiny little invader at the top left of your character. We can have ten lines down but I have kept the first
screen. Press the Esc key to stop it. This won’t do, it needs to be much bigger and last as 0 so there’s a gap on the top and bottom.
for a start and how about we bring our alien to life with some animation…
FONTSIZE determines how big text characters will be. In this
Editor press F2 to display the editor case we have gone with eight times the normal size.
Experiment using much higher numbers like 20 and 30. If
CLS nothing appears, then you’ve gone too big.
DEFCHAR (1, 0, 66, 36, 126, 90, 255, 189,129, 102, 0)
DEFCHAR (2, 0, 24, 36, 126, 90, 255, 255,66, 60, 0) PRINTAT allows us to position the text cursor (position)
FONTSIZE (8) anywhere on the screen. We have set this at 0, 0 or the top
INK = GREEN left of the screen.
CYCLE
We then have a simple loop with a couple of wait commands
PRINTAT (0,0); chr$(1);
so it’s not too fast (try removing or changing the values).
WAIT(0.2)
Using this method it is possible to create all kinds of simple
PRINTAT (0,0); chr$(2);
WAIT(0.2) graphic games and characters. There are limits though as
REPEAT we can only use a single colour and we can’t really make
END anything detailed. That’s Ok though as there other things
we will cover later that will allow us to be much more
creative.
1024 MEGABYTES are called a GIGABYTE, and 1024 of those, a TERABYTE and then
40
In the FUZE BASIC editor change your program or start again to GET WITH THE PROGRAM
make it as follows; Note the numbers have changed a lot!
Project stage 1-4
“It’s all 1s and 0s to me!”
Editor press F2 to display the editor Please grab some graph paper,
CLS a pen and a pencil and, if you are terrible at maths then
DEFCHAR (1, 126, 126, 24, 24, 24, 24, 24,24, 126, 126) maybe a calculator too. Draw the following grid pattern, with
DEFCHAR (2, 0, 36, 126, 255, 255, 255, 126,60, 24, 0) a pen, with the numbers along the top. You want 8 columns
DEFCHAR (3, 0, 66, 36, 126, 90, 255, 189,129, 102, 0) across and 10 rows down.
Then using a
FONTSIZE (8) 128 64 32 16 8 4 2 1 pencil, lightly fill
CYCLE
INK = YELLOW = in boxes to build
your own
PRINTAT (0,0); chr$(1); = characters,
WAIT(0.5) = shapes or
PRINTAT (0,0); chr$(2); symbols. Add
INK = PINK
= up the boxes in
WAIT(0.5) = each row to get
PRINTAT (0,0); chr$(3); = your decimal
INK = GREEN value at the end.
WAIT(0.5)
= You can then
REPEAT = add these to
your program by
END = replacing the
= ones already
there or create
RUN, F3, and all going well you should see an animation playing new ones.
I - Love - Space Invader. We now have three steps to our animation but of
course we could have any number. DEFCHAR (#, specifies the character number that you use
in the PRINT chr$(#) command. Be creative, although it is
You can now change any of these characters by simply changing the numbers. not easy with a small number of pixels to work with…
a PETABYTE, an EXABYTE, a ZETTABYTE and finanlly a YOTTABYTE follow…
41
Stage 1-4 Assessments GET WITH THE PROGRAM
Ok, you’ve learnt some important stuff here. Everything you Project stage 1-4
know is 0 and 1s, but lets see if you’ve really got it…. “It’s all 1s and 0s to me!”
More binary information
Assessment 1 Many of the earliest computers used cardboard to store information.
Change the colours and the delays we used to make the Strips and strips of card with little holes punched through them were
used to feed information into a computer. They became known as
animation show faster or slower. ‘Punch Cards’
Assessment 2
Change one, or all, of the characters for ones you have designed
yourself on graph paper. You will need to replace the numbers
in the DEFCHAR command but remember, the first number tells
the computer which character to replace. If you want to add
Not all punch cards used the same methods but binary was
more then you will need to increase this number. certainly one of them. The cards were fed into a machine reader
that scans for holes in the card. If there is a hole then it returns
DEFCHAR (1, xxx, xxx, xxx, xxx, xxx, xxx, xxx, xxx, xxx, xxx) a value of 1 if there is no hole then a value of 0 is returned.
This series of 1s and 0s are then converted into machine code.
Assessment 3 Machine code is a very complicated programming language but
is, in principle, still very similar to all other languages, including
This one is a bit harder. Can you change the position on the
FUZE BASIC.
screen of the character. Experiment to see how changing the
Today we use very similar methods to store information. The
values in PRINTAT (0,0) make a difference to the location. Compact Disc (CD), DVD and Blu Ray discs all use the same
Remember the first number changes the horizontal position and method. Tiny bumps are made on the inner surfaces of the disc
by firing a laser beam. Again, a laser is used to read information
the second number the vertical position. The characters don’t
back. A 1 or 0 is returned depending on there being a bump or
even need to be in the same position each time….. not.
It’s hard to imagine that nothing more than a long, long line of
End of Stage 1-4 zeros and ones could possibly end up as the latest Taylor Swift
song, but there you go, anything’s possible.
But did you know that the name given to just 4 BITs is a NIBBLE? Comic genius’ those geeks!
42
GET WITH THE PROGRAM
Project stage
“Round Up” For educators:
Mapping with the Curriculum
In this project you will review; While everything up till now is included, this
project raises the complexity level by
Everything we have covered so far but expanding simple loops into conditional ones,
with a much larger program; IF into IF THEN ELSE and ENDIF statements
and, random number generation with RND.
The entire program serves a real purpose and
Commands used
presentation plays an important role too. Text
CYCLE, INK, PAPER, CLS, INPUT, WAIT,
styling and layout is introduced and the
IF THEN ELSE, ENDIF, FONTSIZE,
program flows with a beginning, middle and
PRINTAT, CHR$, RND, FOR, REPEAT,
end to arrive at its purpose.
UNTIL, END, OR, TWIDTH, THEIGHT,
LEN Fasten seatbelts, this is the real thing!
“Gangnam Style” by Psy is still the most viewed YouTube video of all time. It’s been viewed over two billion times
44
In the Editor press F3 to RUN and see how it plays. GET WITH THE PROGRAM
Play the game through a few times and make sure you win and Project stage 1 Round Up
lose so you can see what happens.
Before we jazz things up a bit lets go through and see if we can
make sense of it. The command ‘REPEAT UNTIL
guess = number’ will always return to the CYCLE
The first few lines are easy, CLS, PRINT and a WAIT command. command unless (UNTIL) our ‘guess’ is the same as
These clear the screen, print a couple of lines of text and then (or equal to) the computer’s ‘number’.
pause for one second.
Once we guess the right number then this condi-
In the next few lines we define a few important variables that we tion is met and the program is allowed to pass the
are going to use throughout our game. ‘result$’ is a string (text) REPEAT and go on to the next part where it clears
variable to store ‘too high’ or ‘too low’ in depending on your guess. the screen (CLS) and prints a message.
‘number’ is the computer’s guess. RND (100)+1 picks a random
number from zero to 100. Actually it is from 0 to 99.9999999 so it Just before this, the turn variable is reduced by one
will never pick 100. We add 1 to the result so the ‘number’ is then and if it gets to zero (or less than one) then the mes-
from 1 to 100. sage “Bad Luck!” is displayed and the program ENDs
‘turn’ is the number of player turns left and ‘guess’ is the variable If the correct guess is entered guess = number then
we store your guess in each time. the loop condition is met and the loop will exit and
the message “WELL DONE” is displayed instead.
The CYCLE command starts our main loop. This loop is very
important as it determines the flow of our program. Look for the
line ‘REPEAT UNTIL guess = number’. We know that the variables To make sure you understand how the program
‘number’ and ‘guess’ are where we have stored the computer’s is working try changing the number of turns
choice and our guess. allowed to a smaller one and change the mes-
sages displayed as well.
What's in a name…? Amazon was initially named 'Cadabra', Twitch and Jitter were considered for Twitter and eBay actually stands for Echobay which could have been its name. 45
So, what do you think so far? GET WITH THE PROGRAM
Project stage 1 Round Up
Be truthful, it’s a bit dull isn’t it?… Well, with a bit of tweaking we
can change that. A bit of colour and tidying up will work wonders.
The problem is that we are about to make so many changes it is WAIT (1)
better if we start again. If you are in the editor then press F2 to PAPER = Black
enter Direct mode and then type the following or if you are al- INK = Red
CLS
ready in Direct mode just type it straight away
PRINTAT (1, 1);
NEW (and then press enter) PRINT "I'm very sorry to hear that... Goodbye"
PRINT
Press F2 to return to the editor and type in the following program; WAIT (3)
CLS
END
Editor press F2 to display the editor ENDIF
FONTSIZE (3) Ok, so this is just the start of our new version.
PAPER = Navy
When you RUN it you will see it is more colourful
INK = Lime
CLS and personal, human even. It now asks for your
PRINTAT (1, 1); name and if you would like to play a game.
INPUT "What is your name? ", name$
WAIT (1) If you don’t want to play it says Goodbye. When
PAPER = Maroon you input the Y / N answer it stores your entry
INK = Pink into the string variable A$ and then checks to see
CLS your if answer was anything else other than an
PRINTAT (1, 1); name$;
upper or lower case Y. If it’s not a Y then it prints
INPUT ", would you like to play a game (y/n)? ", A$
IF A$ <> "y" AND A$ <> "Y" THEN the Goodbye message but if it is then it reaches
the end of the program.
It took just four years for the Internet to achieve 50 million users. Radio took 38 years to achieve the same and television 13 years. Today more than 2 billion people use the Internet!
46
Now we need to add the next part. After the last line, ENDIF GET WITH THE PROGRAM
please enter the following statements; Project stage 1 Round Up
I hope that you would also agree with me if I told you that In FUZE BASIC a normal numeric variable is used to
2 + 2 = 5 is a FALSE statement, because the things on the left do this with the value 0 (zero) representing FALSE
hand side do not have the same value as those on the right. and any number other than 0 (for example 1)
representing TRUE. It also has two built in constants
However the statement 2 + 2 <> 5 is actually a TRUE statement called FALSE and TRUE which have the values 0 and
because <> means “Is not equal to” that is the things on the left 1. You cannot change the values of these so for
hand side do NOT have the same value as the things on the right. example TRUE = 0 will give an error.
You may have noticed by now that TRUE and FALSE are exact Conditions
opposites of each other, that is TRUE = NOT FALSE. A condition is a test of whether something is TRUE
or FALSE. For example X = 2 will be TRUE if X has
So, how do we use all of this in a computer program? Well, say
the value 2 but FALSE if it has any other value.
that we have 2 numeric (number) variables called X and Y and I
tell you that X + Y = 2. Is this a TRUE statement or a FALSE one?
Conditional Statements
It will depend upon the values of X and Y. If they both have the These allow a program to carry out different ac-
value 1 then it will be TRUE. If they both have the value 2 then it tions depending on the results of the condition.
will be FALSE (2 + 2 = 4 not 2). Without this our programs would always do the
same things and would not be very interesting!
* This is actually more difficult to prove than you might think!
51
The IF…THEN Command GET WITH THE PROGRAM
The simplest conditional statement is the IF THEN command Project stage 2-1
which looks something like this: “True OR False?”
IF condition THEN
Programming Languages
commands
There are lots of different programming languages
ENDIF
If the condition is TRUE then the commands (there can be more and they all have different commands and ways of
than one) will be RUN but if it is FALSE they won’t be. The ENDIF doing things. However, nearly all will have something
command marks the end of the commands to be RUN (or not!). similar to the IF THEN conditional statement on the
left. Here are a few examples:
Right let’s get programming. I assume by now that you know how to
get FUZE BASIC up and running but if you can’t remember you need
to look back at the first project card (1-1). Python C/C++/C#/Java/PHP
if condition: if (condition)
Once you have done so, press F2 to start the Editor. If there’s another
commands {
program listed then make sure it isn’t needed and then press F12 to
clear it. Then enter the following lines of code: commands
}
Editor Pascal/Delphi
X=1 if (condition) then
begin BASIC/Visual Basic
Y=1
IF X + Y = 2 THEN commands IF condition THEN
PRINT X;" + ";Y;" = 2" end; commands
ENDIF ENDIF
END Don’t worry too much about the details of each
What do you think will happen when the program runs? Press F3 to language. The most important thing is that you
RUN it now and find out. As before you will be prompted to first SAVE understand what a conditional statement is:
your work. Enter a name for your program, for example IF THEN. one that is run when a certain condition is met.
Be careful with this logic stuff! You might prove that black is white and get run over on a zebra crossing!
52
Did you guess correctly? You should have seen the statement GET WITH THE PROGRAM
1 + 1 = 2 printed on the screen because the condition X + Y = 2 Project stage 2-1
is TRUE when X is 1 and Y is 1 (1 + 1 = 2 is TRUE).
“True OR False?”
Now change the value of X and/or Y to something bigger than 1 Flowcharts
and see what happens when you run the program again. This time These are diagrams that show the way that a process
you should get nothing printed to the screen at all. This is because flows. In the example below for the IF…THEN…ELSE
the condition is now FALSE. command the program will either go down the right
side or the left side depending on the outcome of
What if we want to print something out in this case? We could use
the test of the Condition.
two IF commands one testing if the condition is TRUE and the
other if it is FALSE. Luckily we don’t have to. To make our life easier
there is another part to the IF command called the ELSE part.
IF condition THEN
commands
ELSE
commands
ENDIF
In this case IF the condition is TRUE then the commands under THEN The different shaped boxes have different
will be run until the ELSE is reached and if it is FALSE the commands meanings. The rounded ones mark the start
under ELSE will be run until the ENDIF is reached. Now we can change and end of the process, the diamond shape is a
our program to do different things depending on the values of X and Y decision to go one way or another and the
as shown overleaf: boxes are actions to carry out.
If you think this stuff is funny you need to check out the Hitch-Hikers Guide to the Galaxy!
53
Editor GET WITH THE PROGRAM
X = 2 Project stage 2-1
Y = 2 “True OR False?”
IF X + Y = 2 THEN
PRINT X;" + ";Y;" = 2"
NOT!
ELSE As mentioned earlier TRUE and FALSE are exact opposites
PRINT X;" + ";Y;" <> 2" of each other and the NOT operator will reverse them so:
ENDIF TRUE = NOT FALSE and FALSE = NOT TRUE
END
This time when you run the program you should see the statement So, for example, this means that the condition
2 + 2 <> 2 (remember that <> means is not equal to) as 2 + 2 is not A <> B is the same as NOT (A = B).
equal to 2 and the ELSE part of the conditional statement is RUN.
In some programming languages the NOT operator
So we now have a program that tells us that 2 + 2 is not equal to 2. is written as ! and the <> operator is written as !=
This doesn’t seem very useful! Let’s make it a bit more general. Edit
the program as shown below:
NOT Gate
In digital electronics a NOT gate takes an input signal which
Editor is at high (on, 1, +5V or TRUE) and outputs a signal that is at
INPUT "X = ", X low (off, 0, 0V or FALSE) and the other way around.
INPUT "Y = ", Y
Input Output
INPUT "Z = ", Z
IF X + Y = Z THEN 1 0
PRINT X;" + ";Y;" = ";Z 0 1
ELSE
You might use a NOT gate to switch a light on in a
PRINT X;" + ";Y;" <> ";Z
car when the door (and a switch attached to it) is
ENDIF
END open. When the door (and switch) is closed the
input goes to on and the output (and light) goes off.
“We don't need no education” is a double negative which is a positive!
54
This time when you run the program it will prompt you to enter 3 GET WITH THE PROGRAM
numbers (X, Y and Z - press the Enter key between each) and will then Project stage 2-1
tell you if X added to Y gives the result Z (or NOT). Sample outputs
“True OR False?”
from the program are shown in [Pic 1] and [Pic 2] on the right.
String Comparison
[ Pic 1]
Conditional statements work with string variables too. Two strings
are considered equal if they have the same length and all of the
characters match EXACTLY. This means that letters have to be the
same case (capital letter or small ones) and punctuation has to be
the same as well (including spaces).
Say that we want to write a program that prints a different message [ Pic 2]
Editor
INPUT "Enter your Name: ", Name$
IF Name$ = "Dave" THEN [ Pic 3]
PRINT "Hi Dave. Welcome back."
ELSE
PRINT "I don't know you, "; Name$
ENDIF
END
[ Pic 4]
If you run this program and enter the name Dave (followed by the Enter
key) you will get the output shown in [Pic 3]. If you enter any other
name, including DAVE (all in capitals) you will get something like the
output in [Pic 4]. You need to be very careful about case (whether letters
are capital or small) when comparing strings.
Keep going!
55
Multiple Conditions GET WITH THE PROGRAM
What if you wanted to test more than one condition at a time? Project stage 2-1
You could do something like this: “True OR False?”
AND Gate
IF condition1 THEN
In digital electronics an AND gate takes two input
IF condition2 THEN
signals which are either at high (on, 1, +5V or TRUE)
commands
or low (off, 0, 0V or FALSE). If they are both high then
ENDIF
the output is high otherwise it is low.
ENDIF
The commands would only be executed if condition1 is TRUE AND Input A Input B Output
condition2 is TRUE. The AND operator makes this much clearer to
read and understand:
0 0 0
0 1 0
IF condition1 AND condition2 THEN 1 0 0
commands
ENDIF 1 1 1
If I Ruled the World… Hmm… if Colin ruled the world there would be no cars, just trains, bicycles and loud music, oh and tea, lots and lots of tea! 58
GET WITH THE PROGRAM
In this project you will learn; Our first foray into the world of electronics is a
simple but very engaging one.
How to setup and control a simple
Using FOR REPEAT loops we control the direction
electronic circuit;
of electricity around a simple circuit to create an
A simple explanation of electricity
animated sequence of LEDs.
A brief introduction to resistance
Using FOR loops to control program A deliberately layman’s explanation of current flow
flow and resistance is provided to gently introduce
electronics. The real objective is to use simple
Commands & components introduced electronics to further the understanding of basic
PINMODE, DIGITALWRITE, Resistors, programming concepts including FOR loops.
LEDs and Jumper wires.
This tells the computer that this pin (GPIO zero) is now configured
The breadboard has two lines along the top and bottom.
to send out digital signals. Nothing will happen yet though as we They are are connected all the way along until the line is bro-
still need to actually send a signal. ken, after which another line starts again. This allows a signal
to be sent all the way along with just one connection. You
DigitalWrite (0,1) - press enter can then add LEDs and other components along the line to
pass the signal to the main section. In this project we’re con-
That’s better - all going well, the LED should light up [Pic 2] overleaf. necting the blue line to the GROUND socket on the IO board
If not check your connections thoroughly and then swap the LED. using a blue cable. If we want to apply a ground signal to a
new LED we can add one directly onto the blue line.
*I would be very happy if someone could give me a good reason as to why it is called this!
62
You can set any socket from 0 to 7 to PinMode 1 (Digital Out) GET WITH THE PROGRAM
and then send a high signal (1) to it to send power to that pin. Project stage 4-1
Now turn it off by sending a low signal (0) to pin 0 (zero) “Flashing lights”
DigitalWrite (0,0) - press enter
[ Pic 2 ]
Switch to the Editor (F2) and start a new program (F12) and
enter the following;
Press F3 to RUN. After setting Pin 0 to Output mode we can easily send
on (high) and off (low) signals to the pin to switch it on and off.
Set the breadboard up as displayed in [Pic 3] and update the program as Note, we have connected GPIO 1 to the second LED,
shown on the next page… (F2 to go to the Editor) added another resistor and connected the new LED to the
GND signal on the blue track.
I mean, it’s not like they’re big enough to slice bread on, and even if you did then the crumbs would fall into the little sockets and make it pretty useless. A very silly name indeed.
63
Editor press F2 to display the editor GET WITH THE PROGRAM
CLS Project stage 4-1
PinMode (0,1) “Flashing lights”
PinMode (1,1) [ Pic 4]
CYCLE
DigitalWrite (0,1)
Wait (.1)
DigitalWrite (1,1)
DigitalWrite (0,0)
Wait (.1)
DigitalWrite (1,0)
Wait (.1)
REPEAT
END
Press F3 to RUN. Now we have two flashing LEDs! Make sure you connect the cables as follows;
GPIO 0 to the first LED (left to right)
Set the breadboard up as shown in [pic 4] and then Return to the GPIO 1 to the second LED
Editor and rewrite the program as shown on the next page. This will be GPIO 2 to the third LED
a complete rewrite so you might as well just hit F12 to clear the current GPIO 3 to the fourth LED
GPIO 4 to the fifth LED
one. GPIO 5 to the sixth LED
Firstly, six GPIO pins are configured to Digital Output mode using a Notice we have added a resistor to every LED so there are
simple FOR LOOP to set them all to 1 in succession. now six LEDs, resistors and GPIO cables connected in total.
Remember the LEDs have one pin longer than the other,
Then two more FOR LOOPS switch the lights on and off in sequence to
this is the Active pin and it needs to be at the top.
create an animated effect. Now turn the music up and get with the
light show dudes! And one last time, just to be clear, nothing should be
connected to the 3.3 v or 5.5 v power sockets.
So, how small is an atom really? Well, here’s an interesting way to think about it… 64
Editor GET WITH THE PROGRAM
CLS Project stage 4-1
FOR p = 0 TO 5 CYCLE “Flashing lights”
PinMode (p,1)
DigitalWrite (p,0) The next two FOR loops behave very differently to
REPEAT
each other. The first is straightforward as it simply
CYCLE
counts through the pins, 0 to 5 one-by-one, turning
FOR p = 0 TO 5 CYCLE
DigitalWrite (p,1) each one on and then off. We’ve added a short, one
WAIT (0.1) tenth of a second delay with WAIT (0.1)
DigitalWrite (p,0)
The second loop;
REPEAT
FOR p = 4 TO 1 STEP -1 CYCLE FOR p = 4 TO 1 STEP -1 CYCLE
DigitalWrite (p,1)
WAIT (0.1) counts in reverse (STEP-1) from pin 4 to pin 1. It doesn’t
DigitalWrite (p,0) count 0 or 5 as these are taken care of by the first loop.
REPEAT
REPEAT Try changing it to, 5 TO 0 and see how it affects
END the animation. You’ll notice that the first and last
LED's stay on for twice as long as the rest. That’s
A few things to take note of here;
because they’re switched on at the start of both
The first FOR loop is used to configure the the six GPIO pins, 0 to 5, to loops. We want them to look the same all the
digital output mode and at the same time set them all to low (off) with way along so the second loops counts just 4 of
DigitalWrite (p,0). the pins.
It’s generally good practice to set things up exactly how we want them There’s no harm in experimenting here, just make
to be when we start up, so there are no surprises. sure your program looks like it does on the left
before going on to the assessments overleaf.
Take a small sweet, something like a Smartie and pop it in your mouth. Mmm, delicious…
65
Stage 4-1 Assessments GET WITH THE PROGRAM
Try the following challenges. Project stage 4-1
“Flashing lights”
Assessment 1
Assessment 1
Increase the number of LED's to eight, and make sure they’re all
animated. Don’t forget to increase the loop counter! You will need
to add cables to the sockets numbered 6 and 7.
Assessment 2
Adapt the program so all the LED's flash off and on at the same
time. Hmm… how could you speed up the animation by so much it
will look like they are all coming on at once? Don’t delay, you’ll
Assessment 2
work it out.
Assessment 3 Assessment 3
Set up the LED's as shown and then alternate between red and
green.
You’ll need to count in steps and then fill in the gaps, somehow…
Assessment 4
Create your own animated pattern using all three colours. You’re Assessment 4
on your own with this one. Good luck! Rock and roll!
How many atoms are in a Smartie? There are more atoms in one single Smartie than the entire number of Smartie’s ever made since they
started making them in 1937. 50 Million tubes are made each year in the UK alone. In fact, you could probably add Tic-Tacs to this as well! 66
GET WITH THE PROGRAM
In this project you will learn; Using a simple light sensor (LDR) to introduce the
wonderful world of analogue is a great way to
How to use a Light Dependent Resistor; elaborate the use of variables, logic and
The meaning of analogue and digital conditional statements.
The difference between
Most importantly is to develop a solid
Using FOR loops to control program
understanding that contrary to popular
flow
understanding we do not live in a digital world but
an analogue one.
Commands & components introduced
ANALOGREAD, ANALOGWRITE, UPDATE, While it is true that we transfer and consume
INKEY, CIRCLE, TONE media digitally, our interaction with the real world
is more often than not an analogue one.
value = ANALOGREAD(inputPin)
Look no hands! 70
Now try putting your hand over the top of the Light Dependent GET WITH THE PROGRAM
Resistor. You should see the value drop to nearly zero. If you were Project stage 4-2
to shine a very bright light on to the LDR the value should go up “It’s an Analogue World”
to nearly the maximum (255). The more light that shines the lower
the resistance and the higher the voltage is.
Dark
Now let’s make this program a bit more interesting:
Editor
COLOUR=RED
CYCLE
CLS2
Pin0 = ANALOGREAD(0)
HVTAB(10,10)
Normal
PRINT Pin0;" "
Light
CIRCLE(GWIDTH/2, GHEIGHT/2, Pin0 * 2, 1)
UPDATE
WAIT(0.01)
REPEAT UNTIL Inkey = 32
END
This time we are using the value read from Analogue In 0 as the
width of a circle drawn in the middle of the screen (actually I have
Bright
doubled it to make the effect bigger). This time when you SAVE
Light
and RUN the program you will a get a red CIRCLE in the middle
of the screen. The size of this circle will vary depending on how
much light is shining on the LDR.
71
Writing Analogue Values GET WITH THE PROGRAM
This still isn’t very useful is it? What if we want to make a light Project stage 4-2
come on gradually as it gets darker outside? Let’s add a light to “It’s an Analogue World”
our original circuit. Place an LED (Light Emitting Diode) as shown in [ Pic 2]
[Pic 2]. Remember that the longer leg of the LED is the positive (+).
This should go on the left. Connect this leg to Analogue Out 0.
Connect the other leg to GND (0 Volts) using a 100 Ohm resistor
(brown, black, brown, gold).
Now we need another new command analogWrite which takes a
number between 0 and 255 and converts it into a voltage between
0V and 3.3V. Change the program to add this as follows:
Editor
COLOUR=RED
CYCLE
CLS2
Pin0 = ANALOGREAD(0)
ANALOGWRITE(0,255-Pin0)
HVTAB(10,10)
Digital to Analogue Conversion
PRINT Pin0;" "
CIRCLE(GWIDTH/2,GHEIGHT/2, Pin0 * 2, 1) This is the opposite process where we take the
UPDATE numbers stored in the computer and convert
WAIT(0.01) them back into a voltage and then to
REPEAT UNTIL Inkey = 32 something in the real world. Because we only
END store the values at intervals of time the gaps in
between have to be filled in. If the time interval
Notice that we want the value to go down as the light goes up
is small enough our brains can’t spot them!
which we do by subtracting it from the maximum (255).
72
Burglar Alarm GET WITH THE PROGRAM
We can make a simple burglar alarm using only an LDR and an Project stage 4-2
LED. Change the circuit slightly as shown in [Pic 3]. This will set the “It’s an Analogue World”
LED to permanently on. Now CAREFULLY bend the LDR down so [ Pic 3]
that it is facing the LED. Make sure that the pins are not touching!
Finally change the program to look like this:
Editor
Alarm = FALSE
Threshold = 10
CYCLE
CLS2
Pin0 = ANALOGREAD(0)
PRINT Pin0;" "
IF (Pin0 < Threshold ) THEN Alarm = TRUE
UPDATE
WAIT(0.1)
REPEAT UNTIL Alarm Threshold
PRINT "Alarm Activated!"
What do we mean by the word threshold? This
TONE(1,70,440,3)
is a value that when passed triggers an action
END
to occur. In this case it is the amount of light
Wh
that means that someone has passed between
en you run this program nothing will happen until you place a
the LED and the LDR. You need to find a value
piece of paper between the LED and the LDR. Then the alarm will
that always sets off the alarm when someone
be activated. You may need to change the value of the Threshold
does but doesn’t go off just because it is
variable depending on the amount of light where you are. The
getting dark!
TONE command plays a sound but you will only hear this if your
73
Stage 4-2 Assessments GET WITH THE PROGRAM
Try the following challenges: Project stage 4-2
“It’s an Analogue World”
Assessment 1 Conclusion
Can you think how you might use an LDR and an LED to send a Computers are very good at storing and processing
signal from one FUZE to another one? You don’t have to really do it numbers. In order to make them useful we have to
(unless you have 2 FUZEs and you want to try!) turn things in the real world into these numbers.
These can then be stored and even altered by a
Assessment 2 computer. Finally we can change the numbers back
Change the program on page 71 to make the circle get bigger as it into things in the real world.
gets darker rather than smaller. (Hint: see the bottom of page 72)
In the digital world of the computer everything is
Assessment 3 either 1 or 0 (True or False) but in reality these are
Change the burglar alarm program so that a flashing circle is voltages that we have assigned to these values
displayed on the screen when the alarm is activated. (Hint: Draw a (e.g +5V for True and 0V for False). So perhaps it
red CIRCLE, WAIT and then draw a black CIRCLE and WAIT again, is an Anlogue world after all.
REPEAT)
Assessment 4
Change the burglar alarm program and circuit so that another LED
flashes when the alarm is activated (Hint: Project Card 4-1 Flashing
Lights!)
74
GET WITH THE PROGRAM
In this project you will learn; If you are fortunate enough to have the FUZE
Robot Arm then this is a fantastic way to introduce
How to control a Robot Arm using direct pro- ‘real-world’ interaction and control.
gramming commands;
By creating a simple user defined interface the
How to send electrical signals to a circuit
user can control each joint of the Robot Arm.
How to use Procedural programming
How to create a user interface The project encourages the use of Procedural
programming techniques as well as complex
Commands & components introduced conditional choice statements such as SWITCH
PROC, DEF PROC, ENDPROC, ARMBODY, and CASE.
ARMSHOULDER, ARMELBOW, ARMWRIST,
ARMGRIPPER, ARMLIGHT, SWITCH, CASE,
ENDCASE, ENDSWITCH
Written by Key Stages 2, 3, 4 and beyond
Jon Silvera
75
Special Stage 1-1 - The Robots GET WITH THE PROGRAM
Before you attempt this project it is important to have covered some Special Stage 1-1
of the early steps of using FUZE BASIC. Please “Wir sind die Roboter”
be sure to have completed Projects 1-1 and 1-2 before starting this Robota
one. Please setup your FUZE computer and connect the robot arm to The first known use of the word Robot comes from the Czech
one of the available USB ports. It’s best to connect the Arm before “Čapek” brothers and was used in Karel Čapek’s science fiction
running FUZE BASIC and make sure it’s switched on. play “Rossum's Universal Robots”
What do you mean you haven’t built the Robot Arm yet? Well that The original meaning of the word Ro-
just won’t do will it. Ok off you go then and come back once bota, was ”drudgery” or “slave labour”.
you’ve done it, in about three hours I reckon. How awful is that!
Double click the FUZE BASIC icon to begin Robots and computing
Whereas early robotic equipment was generally [ Pic 1 ]
As you will have come to expect, FUZE BASIC will leap into action and based on complex machines
present you with the Ready> prompt. cleverly engineered to perform
a specific labour saving
First of all straighten the robot arm a bit so it’s not all folded up. function, it was not until
See [Pic 2]. Don’t worry if the arm clicks here and there this is just the development of
the gears clicking and nothing actually breaking. integrated circuits
(silicon chips) and small
Type in; Warning: These commands will set the powerful motors and
robot arm moving as soon as you press electronic sensors
ArmBody (1) - press Enter that things really started to progress.
enter. If you don’t type the next [ Pic 2]
ArmBody (-1) - press Enter command the arm will go as far as it can
ArmBody (0) - press Enter and start clicking - you should enter the My favourite robot by far is “Marvin the Paranoid Android” by
ArmBody (0) command to stop it. Douglas Adams and his comedy science fiction story The
Hitchhiker’s Guide to the Galaxy. Marvin is a very, very de-
If at this point you get an error stating “unable to find Robot Arm” or pressed robot and well known for letting us know this with
similar then exit FUZE BASIC using Exit - press Enter quotes like; "My capacity for happiness," he added, "you could
fit into a matchbox without taking out the matches first"
Ha, Robots eh… they’ll never take off. Mind you they said that about flying machines once.
76
Unplug the arm and reconnect it again. Also please make sure the arm GET WITH THE PROGRAM
is switched on [Pic 3]. Start FUZE BASIC again try the above again. If Special Stage 1-1
at this point it doesn’t work, seek help from an adult or if you are an
adult, from a child. On the basis things did work, try the same with
“Wir sind die Roboter”
these other control commands;
Today, robots can be incredibly
ArmShoulder (x) - x can be 1, -1 or 0
complicated machines. Even a
ArmElbow (x) - x can be 1, -1 or 0 small toy robot can have in
ArmWrist (x) - x can be 1, -1 or 0 excess of twenty motors, light
ArmGripper (x) - x can be 1, -1 or 0 sensors, cameras, speech
ArmLight (x) - x can be 1 or 0 synthesis and significant
computing power, all in a
A useful trick to know at this point is that you can repeat the last device six inches tall!
[ Pic 3]
command by pressing the up arrow key and then just edit the number.
Remember though, you still need to press enter. Do androids dream of electric sheep?
Let’s put some of this new found knowledge into action. Press F2 to enter the There are so many questions surrounding robotics but perhaps
Editor. If there’s another program listed then none more so than those concerned over the future of the
make sure it isn’t needed and then press F12 to Editor human race. Are we developing machines that will one day
become intelligent and then decide they should rule the world?
clear it. CLS
PROC ResetArm Some people believe that as mankind evolves we will enhance
Start with the following lines of code- END ourselves more and more with robotic parts and electronic
Press F3 to run the program. You will be DEF PROC ResetArm circuitry. This is known as Cybernetics. The result, the Cyborg
prompted for a file name. Best to name it ARMBODY (0) or for a simpler term, The Man Machine!
ARMSHOULDER (0)
something like “JSrobot” where JS is your initials Where will it end… with the complete annihilation of the
ARMELBOW (0)
so you don’t overwrite someone else’s program. ARMWRIST (0) human race of course, boo!
The purpose of this section is to make sure the ARMGRIPPER (0) Not to worry though as by then we will have transferred our
arm can be instructed to switch everything off, ARMLIGHT (0) consciousnesses into computers and so will live forever and
ENDPROC be permanently connected to the Internet with ultra fast
so absolutely nothing will happen at this point broadband… yay!
Leonardo da Vinci designed and built the first known humanoid robot around 1495.
77
Edit the program to add the following - the grey text is what you GET WITH THE PROGRAM
should already have. You can see how it should look in [Pic 4] Special Stage 1-1
Editor press F2 to display the editor “Wir sind die Roboter”
PROC ResetArm
PROC DisplayInstructions
[ Pic 4 ]
END
…................
DEF PROC ResetArm
ArmBody (0)
ArmShoulder (0)
ArmElbow (0)
ArmWrist (0)
ArmGripper (0)
ArmLight (0)
ENDPROC
SWITCH (Key) The extremely renowned and very prolific science fiction author
CASE 49 Editor Isaac Asimov wrote hundreds upon hundreds of books, articles
ARMBODY (1) and short stories about science and robotics.
CASE 57
ENDCASE ARMGRIPPER (1) He introduced the idea of programming a set of rules or laws into
CASE 50 all robots to protect humankind.
ENDCASE
ARMBODY (-1)
CASE 48 The stories written around these laws are extremely popular.
ENDCASE
ARMGRIPPER (-1)
CASE 51
ENDCASE 1. A robot may not injure a human being or, through inaction,
ARMSHOULDER (1)
CASE 32 allow a human being to come to harm.
ENDCASE
CASE 52 PROC ResetArm 2. A robot must obey the orders given to it by human beings,
ARMSHOULDER (-1) ENDCASE except where such orders would conflict with the First Law.
ENDCASE CASE 13
ARMLIGHT (1) 3. A robot must protect its own existence as long as such
CASE 53 protection does not conflict with the First or Second Law.
ARMELBOW (1) ENDCASE
ENDCASE ENDSWITCH
Asimov later went on to add a new law to precede these -
CASE 54 REPEAT the "Zeroth Law", which focuses on humanity as a whole
ARMELBOW (-1) rather than the individual.
ENDCASE END
CASE 55 DEF PROC ResetArm 0. A robot may not harm humanity, or, by inaction, allow
ARMWRIST (1) ArmBody (0) humanity to come to harm.
ArmShoulder (0)
ENDCASE ArmElbow (0) There are many debates as to whether we should impliment
CASE 56 ArmWrist (0) a similar set of rules into modern day robots.
ARMWRIST (-1) ArmGripper (0)
ArmLight (0) Personally, I think we’ll need something, otherwise who
ENDCASE
ENDPROC knows what might happen.
Some scientists and computer futurists predict that robots will emerge as their own species by 2040, with feelings and expectations.
80
Editor GET WITH THE PROGRAM
DEF PROC DisplayInstructions
CLS
Special Stage 1-1
FONTSIZE (2) “Wir sind die Roboter”
INK = Red
PRINT “We are the ROBOTS!” More about Inkey
INK = White The Inkey command is a very important one that you will use over
HVTAB (0,2) and over again. For example, we can use Inkey to pause any
PRINT “Press” program to wait (LOOP) for a key to be pressed;
PRINT
PRINT “1 or 2 for Body left & right” PRINT “Press any key to continue”
PRINT “3 or 4 for Shoulder up & down” CYCLE
PRINT “5 or 6 for Elbow up & down”
PRINT “7 or 8 for Wrist up & down” REPEAT UNTIL INKEY <> -1
PRINT “9 or 0 for Gripper open & close”
If no key is being pressed the the value of INKEY is -1.
PRINT “Enter to turn the Robot light on”
INK = Red Whenever a key is pressed its code value is stored in INKEY. So
PRINT the above loop will repeat until Inkey is not equal to -1.
PRINT “Space to stop movement & switch light off”
ENDPROC This also means we can check if a specific key is pressed. For example
the value of the space bar is 32 so we could change the above to;
So two new things here; firstly the INKEY statement. This is a very
useful command indeed. Please read the opposite page - “More PRINT “Press the Space bar to continue”
CYCLE
about Inkey”. REPEAT UNTIL INKEY = 32
In our program we are storing the value of Inkey (the code value of This time the program waits specifically for the space bar to be
any key pressed) in the variable Key pressed and anything else will be ignored.
Here’s a few more INKEY codes, just in case you need them.
The rest is much easier than it looks. The SWITCH and CASE
48 - 0 49 - 1 50 - 2 51 - 3 52 - 4 53 - 5
commands check the value stored in Key and depending on the value
54 - 6 55 - 7 56 - 8 57 - 9 65 - a 66 - b
performs the command(s) in the relevant CASE section. 67 - c 68 - d 69 - e 70 - f 71 - g 72 - h
73 - I 74 - j 75 - k 76 - l 77 - m 78 - n
So if the “1” is pressed, the code value is 49 (see reference chart
79 - o 80 - p 81 - q 82 - r 83 - s 84 - t
opposite) and so the command, ARMBODY (1) is excecuted. 85 - u 86 - v 87 - w 88 - x 89 - y 90 - z
32 - Space Bar 13 - Enter
It’s always nice to have something to look forward to!
81
Special Stage 1-1 Assessments GET WITH THE PROGRAM
Time to prove you’ve mastered the robot arm project. Special Stage 1-1
“Wir sind die Roboter”
Control commands
Assessment 1
The commands are;
Practice moving different parts of the robot around in Direct ArmBody (x)
mode? Remember F2 switches between Direct mode and the ArmShoulder (x)
ArmElbow (x)
Editor.
ArmWrist (x)
ArmGripper (x)
Assessment 2 ArmLight (x)
Can you write a different program to display (PRINT) differerent
Where x is 1, -1 or 0
things at different locations on the screen. Remember to Save your The light is just 1 or 0
work before entering the NEW command to start a new program.
HVTAB (x,y)
Assessment 3 Remember, HVTAB places the
Write a new program to repeat a series of Robotic movements. cursor at a set position. X is the
Use the WAIT command to determine how far each movement horizontal and Y is the Vertical.
goes.
*The album, The Man Machine by the German band Kraftwerk, has a very good song about Marvin the paranoid android, by Douglas Adams from
Robots on it called “We are the Robots”, but of course it was originally in German, hence the project title. The Hitchhiker’s Guide to the Galaxy
82
GET WITH THE PROGRAM
Appendix
For educators:
Mapping FUZE BASIC
with the Curriculum
Use technology purposefully to create, organise, store, manipulate and retrieve digital content.
Projects 1-2, 1-3
Use technology safely and respectfully, keeping personal information private; identify where to go for help and support when
they have concerns about content or contact on the Internet or other online technologies.
Not directly relevant to programming
85
Key Stage 2 GET WITH THE PROGRAM
Appendix
Mapping FUZE BASIC with the
Curriculum
Design, write and debug programs that accomplish specific goals, including controlling or simulating physical systems; solve
problems by decomposing them into smaller parts.
All projects but start with 1-1 to 1-4 and Round up. Note control and physical systems are included in 4-1, 4-2 and SS 1-1
Use sequence, selection, and repetition in programs; work with variables and various forms of input and output.
Projects 1-2, 1-3, Round Up, 2-1
Use logical reasoning to explain how some simple algorithms work and to detect and correct errors in algorithms and programs.
All projects but start with 1-1 to 1-4 and Round up
Understand computer networks including the Internet; how they can provide multiple services, such as the world wide web; and
the opportunities they offer for communication and collaboration.
Not included at this time but further Projects will include networking, TCP/IP, Internet and other protocols.
Use search technologies effectively, appreciate how results are selected and ranked, and be discerning in evaluating digital content.
Not directly relevant to programming
Select, use and combine a variety of software (including Internet services) on a range of digital devices to design and create a range
of programs, systems and content that accomplish given goals, including collecting, analysing, evaluating and presenting data and
information.
All projects
Use technology safely, respectfully and responsibly; recognise acceptable/unacceptable behaviour; identify a range of ways to
report concerns about content and contact.
Not directly relevant to programming
86
Key Stage 3 GET WITH THE PROGRAM
Appendix
Mapping FUZE BASIC with the
Curriculum
Design, use and evaluate computational abstractions that model the state and behaviour of real-world problems and physical
systems.
All projects but start with 1-1 to 1-4 and Round up. Note control and physical systems are included in 4-1, 4-2 and SS 1-1
Understand several key algorithms that reflect computational thinking [for example, ones for sorting and searching]; use logical
reasoning to compare the utility of alternative algorithms for the same problem.
At this time this is not comprehensively covered but these projects do offer an insight; 1-2, 1-3, Round Up and 2-1
Use two or more programming languages, at least one of which is textual, to solve a variety of computational problems; make
appropriate use of data structures [for example, lists, tables or arrays]; design and develop modular programs that use procedures
or functions.
FUZE BASIC is a text based language. All projects.
Understand simple Boolean logic [for example, AND, OR and NOT] and some of its uses in circuits and programming; understand
how numbers can be represented in binary, and be able to carry out simple operations on binary numbers [for example, binary
addition, and conversion between binary and decimal].
Projects 1-4, 2-1 and 4-2
Understand the hardware and software components that make up computer systems, and how they communicate with one
another and with other systems.
Not directly relevant to programming but there are a number of projects that communicate with external devices. These
include 4-1, 4-2 and SS 1-1
87
Key Stage 3 continued GET WITH THE PROGRAM
Appendix
Mapping FUZE BASIC with the
Curriculum
Understand how instructions are stored and executed within a computer system; understand how data of various types (including
text, sounds and pictures) can be represented and manipulated digitally, in the form of binary digits.
Projects 1-2, 1-3, 1-4, Round Up and 2-1
Undertake creative projects that involve selecting, using, and combining multiple applications, preferably across a range of devices,
to achieve challenging goals, including collecting and analysing data and meeting the needs of known users.
Projects 1-2, 1-3, 1-4, Round Up and 2-1
Create, re-use, revise and re-purpose digital artefacts for a given audience, with attention to trustworthiness, design and usability.
Not covered
Understand a range of ways to use technology safely, respectfully, responsibly and securely, including protecting their online
identity and privacy; recognise inappropriate content, contact and conduct and know how to report concerns.
Not directly relevant to programming
88
Key Stage 4 GET WITH THE PROGRAM
Appendix
Mapping FUZE BASIC with the
Curriculum
All pupils should be taught to: develop their capability, creativity and knowledge in computer science, digital media and
information technology.
All projects
Develop and apply their analytic, problem-solving, design, and computational thinking skills.
All projects
Understand how changes in technology affect safety, including new ways to protect their online privacy and identity, and
how to identify and report a range of concerns.
Not directly relevant to programming
89
fuze.co.uk