Understanding how the
library works
The GoGo library is written entirely in Logo. I
could have put the code in the procedures page, but it would clutter the
screen. To avoid this mess, the Logo procedures are kept in a separate
text file instead. So, you need to load this file into Microworlds
before you can use it.
The library requires you to initialize it once
before use. This is easily done by calling "gogoinit" It setups
all the necessary variables and opens the serial port.
The last requirement is you need to keep a
procedure called "GoGo" running while communicating with the GoGo board.
This procedure makes sure that all commands are properly delivered to
the GoGo board and handles scheduling when multiple commands are
accessing the GoGo board at the same time.
How to initialize and
use the GoGo library
- Load the GoGo library procedures into
Microworlds.
.ask "sys [evalstring filetostring "gogo_mt.txt]
- Initialize the library
gogoinit
- Before using any GoGo commands, run the "GoGo"
procedure. You can do this by creating a button with the instruction
"GoGo" and running "many times." Or you can use the command
forever [GoGo]
Note:
- Step 1. and 2. need to be executed only
once. But step 3. needs to be running every time you communicate
with the GoGo board.
- In the GoGo template, step 1 and 2 are
called in the "Startup" procedure which is a Microworlds special
procedure that runs automatically every time the project is
loaded.
|
|