3.2.3 Programming SoftwareBesides using Cricket Logo, it is also possible to program Crickets with a graphical user interface. At the MIT Media Lab, a program called "Logo Blocks" was developed. It runs on Apple Macintosh computers and uses appealing puzzle-style elements which are connected to each other in order to visualize a program structure. At the CCE on the other hand, "GrafLogo" was created as a diploma thesis. Running on Windows 95 machines, this interface program basically follows ISO rules for flow diagrams.
Both approaches – graphical user interfaces as well as Logo source code programming – have certain advantages and shortcomings. The following sections try to explain and illustrate the differences.
- Cricket LogoThis brief introduction to Cricket Logo (adapted from ) lists and explains the operators and constructs that are already supported by the first version of the Cricket ("Green Dot Cricket", which is being used at the CCE). Later versions still work with this code, their command resources are merely extended.
Procedures:Procedures are defined using Logo ‘to’ and ‘end’ syntax:
Motors:The Cricket can control two motors, which are named A and B. A bi-color LED indicates the state of each motor.
Motor commands are used by first selecting the motor (using ‘a,’, ‘b,’, or ‘ab,’) and then telling it what to do (e.g., ‘on’, ‘off’, ‘rd’, etc.)
Timing and Sound:The timing commands are useful to cause the Cricket to do something for a length of time. For example, one might say ‘ab, on wait 20 off’ to turn both motors on for two seconds.
Please note that there are two different reference values for timing: 0.1 second units, used in ‘wait’, and 0.004 second units, used in ‘note’ and ‘timer’.
Sensors:The Cricket can read two sensors, named A and B.
Program Control:Cricket Logo supports the following control structures:
Numbers:Cricket Logo uses 8-bit numbers. All number are within 0 to 255. All arithmetic operators must be separated by a space on either side. E.g., the expression ’3+4’ is not valid! Use ‘3 + 4’ instead.
Global Variables:Global variables are created using the ‘global [list]’ directive at the beginning of the procedures buffer. E.g., ‘global [hello, world]’ creates two globals, named ‘hello’ and ‘world’. Additionally, two global-setting primitives are created: ‘sethello’ and ‘setworld’. Thus, after the global directive is interpreted, one can say ‘sethello 3’ to set the value of ‘hello’ to 3, and ‘sethello hello + 1’ to increment the value of ‘hello’.
Procedure Inputs and Outputs:Procedures can accept arguments using the colon syntax. E.g.,
to abc :timescreates a procedure named ‘abc’ that takes an input which is used as a counter.
Procedures may return values using the ‘output’ primitive; e.g.,
to goThe ‘go’ procedure will execute 1, 2, or 3 times depending on the value of sensor A.
IR Communication:Crickets can send infrared signals to each other using the ‘send’ primitive, and receive them using the ‘ir’ primitive. The ‘ir’ primitive reports the value sent by ‘send’ less a constant offset of 127; e.g., if one Cricket issues a ‘send 128’, another Cricket’s ‘ir’ primitive receives a 1.
While a Cricket is not running a procedure, codes from 128 to 134 are interpreted to launch one of the seven command lines on the Cricket Logo screen. Household TV remotes may also be used to cause the Cricket to launch one of its seven command lines. Use a Sony remote, or a universal remote set to talk to a Sony TV, and use the keys numbered 1 through 7.
- Graphical User InterfacesLogo is a fairly simple programming language, compared to other procedural languages like Basic or Pascal, but it is still hard for kids to get started. Especially the fact that all arithmetic operators must be separated by a space on either side has proved to be a source of frustration for many kids.
Although this kind of initial frustration may be necessary from an educational point of view, i.e., to understand that computers do not ‘think’ but just follow the programmer’s detailed instructions, both the MIT Media Lab and the CCE have decided to develop graphical user interfaces for Cricket Logo.
"Logo Blocks" has been designed at the MIT Media Lab and runs on Apple Macintosh PowerPC computers with at least 32MB of RAM. It is an iconic version of Cricket Logo, allowing the user to design programs by dragging blocks (each containing a bit of Logo code) from a palette and assembling them into a "stack", after which they may be downloaded to the Cricket. On the Macintosh, this is done by connecting the "Interface Cricket" to the modem port.
Impressive about Logo Blocks is its clearly arranged screen design. This is achieved by subdividing the palette options into the four groups called Action, Control, Sensor, and Procedure. Thus, not all blocks need to be shown at the same time, and the selection is provided dynamically depending on the selected group. Logo Blocks needs no lines to be drawn in order to connect the elements, the puzzle-style connectors already represent connections.
At the CCE, however, no Macintosh computers are available, therefore the "GrafLogo" user interface has been designed for Windows 95 machines. It was completed earlier this year as a diploma thesis. The thesis documentation contains a profound description of the GrafLogo program, so the following is only a brief introduction.
The GrafLogo interface design is entirely in German language. As kids can only use English programs at the age of about 13, since they start learning English in the 5th grade, this approach was chosen in order to allow even younger kids to use the program. There is very little text on the screen, anyway. All elements and options are selected using the mouse. The user can literally put the keyboard aside.
Even complex structures are created by mouse clicks, as context menus and property dialog boxes open up when you click the right mouse button, which is the usual procedure in Windows 95. In the dialogs, only the allowed choices are presented at a time, all others are grayed out. This avoids the input of invalid commands from the beginning.
These are selected dialog boxes and a context menu from GrafLogo:
On the screen, the needed elements are selected, arranged, moved, and given properties and values; then, they are linked in flowchart style. All elements and symbols are oriented at the ISO rules for control flow diagrams.
Sensors and motors can be given real names, which has been requested by many kids during the beta testing – using aliases like "steering" and "rear_bumper" instead of the expressions "motor a" and "sensor a" leads to less confusion and helps to understand the program at a later time.
GrafLogo’s screen design and the way it is used make the program intuitive and give kids the confidence that it is just as easy to work with as any Windows 95 program they know. By avoiding to confront younger kids with plain source code programming, you can keep them motivated and still give them a sense of achievement, as they can on their own ‘tell the Crickets what to do’.
Internally, the GrafLogo software uses a quite complicated method of "potentials" to translate the object-oriented diagrams into plain Cricket Logo code, including loops and branches. This will not be discussed here, please refer to the GrafLogo documentation for further details.
Once the Logo code is generated, it can be looked at before being transferred to the Cricket via the so-called Interface Cricket on the PC’s serial communications port. The possibility to see the code is optional, but it can be very interesting to show the kids the way to "real" programming.
For a proficient programmer, neither "Logo Blocks" nor "GrafLogo" can be as efficient as the plain Cricket Logo source code. But in the CCE environment, where most kids do not have a lot of experience with programming languages, these graphical user interfaces are an interesting approach to realize simple applications for Crickets.
The fact that the two programs are just front ends which translate visual elements into Logo code is very helpful when improvements to a Logo program are needed: kids can analyze and understand the generated code, then change it to fulfill their requirements. By doing so, they can optimize the code or add Logo functionality that is not supported by the graphical interface, e.g. calculating functions or procedures that can take and return parameter values.
"Logo Blocks" and "GrafLogo" are easy to learn, and thus gives mentors and kids at Computer Clubhouses a visual environment, where they can quickly set up a program for a new Cricket application. "Cricket Logo" on the other hand is a powerful programming language supporting all functions a Cricket can provide.