an introduction to programming using the BasicX micro controller, if
you have never programmed before this will help you on your way. More
experienced readers should still skim through this to get the basics
of the language.
Programming is a common language between you and your Robocore, it
lets you tell it what to do. In robotics, programming is necessary to
make machines that can work by themselves, without human intervention.
These are called autonomous robots.
start by connecting your Robocore to the power supply and the serial
port of your computer, and loading up the BasicX software.
this is loaded, click on the Monitor Port menu and select the COM port
that the Robocore is connected to (probably COM1). The Download Port
menu should be set to the same COM port.
the editor button. A window should open asking for a filename. Just
type a name for your first program, lets say Demoprog. It will tell
you that the file does not exist, so do you want to create it. Click
write our first program!
that the BasicX is working, we will make it send a message back to
your computer. This is done using the debug.print command.
following program into the editor window (or copy and paste it). The
first and last lines should already be present, if they are just copy
the middle line.
debug.print "Robocore test: Everything is working"
Before we can download
to the BasicX we need to set the chip preferences. This basically
tells the chip what we want to be doing with each pin (input, output
etc). To do this click on the project menu, followed by chip (or the
F7 shortcut). We can leave everything as it is for now so just click
click on the Compile menu and select Compile and Run (keyboard
shortcut F5) This will send the code to the Robocore. Going back to
the main BasicX window, you should see the text ' Robocore test:
Everything is working ' appear on the screen.
main() and End Sub commands tell the Robocore where the program begins
debug.print command is very useful for telling us what the Robocore is
doing, in the next case we will see more of its capabilities.
will make the Robocore solve an equation for us. To do this we will
need a variable. This is a value stored under a name in the memory of
the Robocore. We will give this variable the name ' answer '.
answerI As integer ' declaring
answer As string ' variables
= 5*5 ' doing the maths
'convert to printable format
debug.print "5 times 5 is "; answer 'print answer
program as before and you should get the computer telling you the
program shows that you can print values from your program to the
screen using debug.print just by adding a semi-colon and the variable
name after the "text", this is very handy for example when testing
program also uses comments, these have no effect on the program but
allow us to add information about each line of the program. The
computer ignores everything written on the line after an apostrophe
program has also introduced us to variables, the topic for the next
tutorial in the programming series