CODE
Variables
Globals
Globals are variables that can be used anywhere in your code.
block_type
A global variable that contains the type of the Cubelet currently running the program. Can be compared to any of the Cubelet Types listed below.
block_value
Each Cubelet has a block_value, a number 0-255. This number is what determines most blocks behavior. For example, a Drive Cubelet with a block_value of 255 will drive at full speed; if there is an object really close to a Distance Cubelet, it's block value will be close to 255, if there is no object, it's block_value will be 0.
neighbor_data
An immutable object containing information about a Cubelets neighbors. Most Cubelets use neighbor_data when calculating their block_value. At present, neighbor_data is a private object whose data cannot be accessed.
Constants
Constants are variables that can be accessed anywhere in your code, but cannot be modified.
BACKWARD
A constant useful for setting the direction of a motor in a Drive Cubelet or a Rotate Cubelet.
FORWARD
A constant useful for setting the direction of a motor in a Drive Cubelet or a Rotate Cubelet.
Cubelet Types
Cubelet Types are global constants that can be used to programmatically determine the type of a Cubelet.
BAR_GRAPH_CUBELET
BATTERY_CUBELET
BLOCKER_CUBELET
BRIGHTNESS_CUBELET
DISTANCE_CUBELET
DRIVE_CUBELET
FLASHLIGHT_CUBELET
INVERSE_CUBELET
KNOB_CUBELET
MAXIMUM_CUBELET
MINIMUM_CUBELET
PASSIVE_CUBELET
ROTATE_CUBELET
SPEAKER_CUBELET
TEMPERATURE_CUBELET
void setup()
{
}
void loop()
{
    think();
}
void think()
{
    switch(block_type)
    {
        case MINIMUM_CUBELET:
            block_value = minimum(neighbor_data);
            break;
        case MAXIMUM_CUBELET:
            block_value = maximum(neighbor_data);
            break;
        case INVERSE_CUBELET:
            block_value = weighted_average(neighbor_data);
            block_value = inverse(block_value);
            break;
        case PASSIVE_CUBELET:
            block_value = weighted_average(neighbor_data);
            break;
        default:
            break;
    }
}