Yellow Brick Logo understands the following Logo commands:
The View button may be used to cycle through a display of the three sensor values and the numeric display. A caret indicates which sensor port is being displayed. While viewing sensor values, holding down the Prgm button will display counter value rather than direct sensor reading (in other words, if you are using a counter on a given sensor, hold down the Prgm button to see the counter value.)
Make sure there is a space between all arithmetic operators. E.g, "if sensor1>500 [beep]" won't work, use "if sensor1 > 500 [beep]" instead.
Use parentheses to get expressions to parse the right way. E.g.:
if (sensor1 > 500) and (sensor2 > 500) [beep]
Numbers range from -32768 to +32767. "true" is any number but 0; "false" is zero.
<
Inputs to procedures are done using standard "dots" Logo syntax; e.g.:
to double :n output :n * 2 end
Global variables are defined using phrase "global [gname1 gname2 ...]" at beginning of procedures buffer. This creates reporter named "gname1" and modifier named "setgname1" for each global. For example:
global [foo] to test setfoo 3 print foo + 4 end
When running the test procedure, the number 7 is printed.
Yellow Brick Logo automatically defines n and m as user globals.
Local variables are defined using the let primitive, set using the make primitive, and accessed using the "dots" (colon) operator. The following demonstrates creating, accessing, and setting a local variable:
to local-test let [x 3] print :x wait 10 make "x 4 print :x end
Arrays are declared using the keyword array at the beginning of the procedures buffer. For example,
array [foo 10 bar 20]
creates an array named foo consisting of 10 elements, and an array named bar consisting of 20 elements.
Array elements are set with the aset primitive, which takes three inputs: the name of the array, the index, and the value. E.g.:
aset foo 5 23
sets element 5 of array foo to the value 23.
Array elements are accessed with the aget primitive, which takes two inputs: the name of the array and the index. E.g.:
aget foo 5
retrieves element 5 of array foo.
Array indicies start at zero. Therefore an array of ten elements would use indicies 0 through 9. There is no error checking to verify that array operations are within the bounds of array declarations.
Multiple RCX bricks can communicate with each other using infrared communications commands. Please note that RCX bricks running MIT Logo firmware cannot communicate with RCX bricks running LEGO firmware. RCX bricks running MIT firware can only communicate with other RCX's running MIT firmware.
The IR communications is byte-oriented. One brick sends a byte, and another brick receives it.
To send a byte, use the send value primitive. value should be a number in the range of 0 to 255.
To receive a byte, use the ir primitive. ir returns the last byte received.
To test if a new byte has been received, check the newir? primitive. This will return true the first time checked after a new IR byte has been received.
Here is an example. On one brick, run the following command to randomly send the number 1, 2, or 3 every second:
every 10 [send 1 + (random % 3)]
On the second brick, run the following program, which waits until an IR value is received, and then chooses one of three actions based on its value:
to irdemo loop [ waituntil [newir?] if ir = 1 [beep] if ir = 2 [a, onfor 5] if ir = 3 [b, onfor 5] ] end
Yellow Brick Logo supports up to 8 concurrent tasks. There are three kinds of tasks: a periodic task, which runs repeatedly at a fixed interval, a conditional task, which runs each time that its condition becomes true, and a background task, which runs continuously.
The periodic task is created with the every primitive. For example:
every 30 [beep]
will cause the RCX to start beeping, making a beep every 3 seconds.
The conditional task is created with the when primitive. For example:
when [switch1] [beep]
will launch a task that continually checks the state of switch 1. Each time the switch is pressed, the RCX will beep.
Note that the conditional task is edge-triggered. This means that it fires only once for each time that the condition becomes true. Thus, in the switch 1 example, the RCX will not keep beeping if the switch is held down. The when fires only once each time the switch goes from false to true.
The background task is started with the launch command. This is typically used in conjunction with loop to keep the background task running. For example, if it is desired to have an action repeatedly taken while a condition is true, build a loop and test for the condition using the if statement, and then get it going with launch:
launch [loop [ if switch1 [beep] ]]
The following program will repeatedly check light sensor 1. If it's too dark, motor A will be turned on. If it's light, motor B will be turned on:
to follow-line-edge loop [ ifelse sensor1 < 600 [a, on b, off] [a, off b, on] ] end
The next example will turn motor A on. When touch sensor 1 is pressed, motor A will reverse for 2 seconds, and then go forward again. The whole time it's doing this, it will beep every 3 seconds, just for fun:
to back-and-forth a, on when [switch1] [rd wait 20 rd] every 30 [beep] end
Note that the when and every commands each launch a process to do their work for them.
Click the Download button on the screen to download all procedures and the run-line code.
Press the green Run button on the RCX to run the run-line code.
While a Logo program is executing, an animated display of 5 dots will be shown on the RCX screen. Press the Run button to stop the program from running.
When running MIT Logo, the RCX will automatically power off after ten minutes since you last interacted with it, even if it's running a Logo procedure.
The RCX may be put to sleep under program control using the sleep primitive.
In order to keep the RCX alive, run the resetpd (reset power down) primitive, at least once every ten minutes.