Strawbees CODE flow and block code documentation for Quirkbot.
Strawbees CODE flow and block code documentation for Quirkbot.
Diversity of programming languages and paradigms is important because there is no programming language is better than the others. On Strawbees CODE learn to create code in 3 ways as different languages are great for different kinds of problems.
Block and flow is visual programming. Block programming is connecting Scratch-based blocks while flow is a network of boxes, also known as nodes, continuously sending data. The colorful nature of the blocks and nodes makes it easier to describe the process of what’s happening with the Quirkbot on screen. Text is a traditional method of writing programs. On Strawbees CODE text is written as C++ text like a regular Arduino compatible board.
Using Quirkbot enables interactive systems to be created. When programming generally you will use a combination of the color-coded node categories, Input, Brains, and Output to make your system do what you want.
Block programming is snapping drag-and-drop blocks together to create scripts. These scripts are composed to create a sequential, step-by-step set of instructions similar to Scratch blocks.
The blocks on Strawbees CODE is based on MIT Media Lab’s Scratch blocks. Refer to the Scratch Wiki for more extensive information about the blocks.
Nodes getting information from the physical world.
place
- The physical place (horn
, left arm
, right arm
, left leg
, or right leg
) the light sensor is based on value of how much light the Quirkbot senses.Blocks with the ability to control something in the physical world.
Control blocks are the blocks that control scripts.
Pauses the script for the amount of time.
A loop that repeats the specified number of times.
A loop that will continuously run forever. The forever block can yield to other commands within the program.
Checks the condition so that if the condition is true, the blocks inside it will activate.
Checks the condition so that if the condition is true, the blocks inside the first half will activate. If the condition is false, the blocks inside the second half will activate.
Pauses the script until the condition is true.
Operator blocks perform math functions with numbers and string handling.
The value of the addition.
The value of the subtraction.
The value of the multiplication.
The value of the division.
Picks a random number between the two limits.
The condition for checking if a value is greater than the other.
The condition for checking if a value is less than the other.
The condition for checking if two values are equal.
True if both conditions are true.
True if either condition is true.
Makes the condition checked if it is false, not true, or true, not false.
The remainder of the division.
Rounds the value to the nearest whole number.
The absolute value (abs), square root (sqrt), sine (sin), cosine (cos), tangent (tan), asine (asin), acosine (acos), atangent (atan), natural logarithm (ln), logarithm (log), exponential function (e^), or base 10 exponential function (10^) of a specified value.
Variables blocks are the blocks that hold variables and lists.
The variable's value.
Sets the specified variable to the amount.
Changes the specified variable by the amount.
Event blocks control events and trigger the program. Strawbees CODE uses 2 Event blocks:
When the program is uploaded to the Quirkbot, the block script activates.
The event is activated when triggered by an input.
My Blocks are user-made custom blocks.
Defines a custom block.
Defines a custom block.
An input for a value, set by the definition My Block.
A true/false value.
Flow is a visual programming language connecting nodes together to send data from one to another continuously. Flow-based programming works with visual nodes. This paradigm suited for thinking in a general way about systems and overview of what you want to do instead of explaining it in step-by-step instructions. Using Flow programming is great for prototyping a variety of functions and not having to rewrite lines of code.
Connections send data from one node to another. Make a connection by dragging the outlet of a node and dropping it in the parameter of another node. Once connected, data flows continuously from the outlet to the parameter.
Parameters hold values that are important to the node. By changing the values, you change how the node works. You decide if a parameter is fixed or connected to an outlet. A fixed parameter’s value doesn’t change. A connected parameter’s value changes when the connected outlet changes.
Many nodes have number parameters. Set their value by using the slider or by typing directly into the box. Most number parameters go from 0 to 1, enabling you to connect them directly to most outlets.
Some nodes have option parameters. Select their value by clicking on an item from the drop-down list, or by writing the exact name of the option in the box.
Many input and output nodes have a place option parameter (horn, left arm, right arm, left leg, or right leg) that presents where they exist in the physical world.
Many nodes have minimum and maximum (min and max) number parameters that control the smallest and largest values sent by the outlet.
Nodes getting information from the outside world.
Turns the arms, legs or horn into a circular touch sensor. It detects when a weak current flows from the front to pad to ground. The ground can be the left eye or the back pads of the arms, legs, or horn. Because it's very sensitive, the current can flow through your body or anything else that has water in it, or is otherwise conductive (like metals). To activate the sensor, simply pinch the arm that you choose as the place.
Reads an analog value from a physical light sensor connected to the arms, legs, or horn of the Quirkbot. It gives the light sensor power from the front pad and reads the back pad to determine the amount of light hitting the sensor. It also works with other sensors based on resistance.
Self-calibrating version of the Light Sensor node. Reads an analog value from a physical light sensor connected to the arms, legs, or horn of the Quirkbot. It continuously calibrates the value to get the maximum range. It gives the light sensor power from the front pad and reads the back pad to determine the amount of light hitting the sensor. Also works with other sensors based on resistance.
Control the DIY IR Proximity backpack. The IR Proximity detects the amount of infrared light from an IR-LED that reflects from back to an IR Detector.
For using the DIY Kit backpack to connect to a Grove Ultrasonic Ranger from Seeed Studio. The Sonar measures the distance to an object by bouncing ultrasound in its surface.
Reads an analog value. Checks how much voltage is applied to a physical input on the Quirkbot that has analog read capability. This can be used by connecting external electronic components such as potentiometers or resistors.
Read a digital value. Checks if there is voltage, or not, applied to a physical input on the Quirkbot that has digital read capability. This can be used by connecting external electronic components such as buttons and switches.
Nodes that manipulates or generates information.
A waveform generator. Create a wave that oscillates (continuously swings back and forth) between two numbers. There are a number of different Waveforms (types of waves) that can be selected. The Wave node can be used in many situations like moving a servo motor back and forth, blinking an LED, or iterating through a list from the List node.
Send out a random number at a given interval.
Counts the number of seconds elapsed since the Quirkbot is powered up. Can be used together with the comparison node to trigger time based events.
Perform a common arithmetic operation with two numbers. Addition, subtraction, multiplication, division and modulo operations are available.
Compares two values and evaluates the result. The number going to in is compared to the number in value, and the type of comparison is selected with operation. If the result of the comparison is “true” (for example if in is 1, operation is == Equal, and value is 1) then the number in then is sent to the outlet. If the comparison is “false” (for example, if in is 0, operation is > Greater, and value is 1) the number in else is sent to the outlet. This is a powerful node that can be used in many ways.
Three common logic gates: AND
, OR
and XOR
. When adding more than 2 items
(inputs) the logic gates are automatically chained together.
Performs a statistical analysis on a number of input items. Operations available are: Average value, Minimum value, Maximum value, and a Summation of all the values.
Constrain any number to be kept inside a limited range. The number sent to in will go unchanged to the outlet if it lies between the values in min and max. If it’s higher than max then max will be sent to the outlet. If it’s lower than min then min will be sent to the outlet.
Convert a stream of numbers from one range to another range. This node can be used to amplify, compress, shift, or invert a range. This can be useful in many situations, for instance to change the numbers coming from an input node, to better match the behavior wanted in an output node.
Gate is used to turn on and off a stream of numbers. It's inserted between two other nodes to stop or allow data to go from one to the other.
Create a list of any numbers or values. You can add up to 100 items by clicking the + sign and removing items by clicking the - sign next to them. The items on the list can also be used as routable inputs for any stream of numbers.
Create a sequence of any numbers and values. You can specify how long it will take for the sequence to run through all the values, and trigger
a run. After a run, the sequence will stop, and is ready to trigger
again.
Counts from 0 by a certain amount every time it receives a trigger pulse. There is currently no way to reset the counter.
Nodes with the ability to control something in the physical world.
Control Light-Emitting Diodes (LEDs). It controls both LEDs integrated in the Quirkbot like the eyes, or loose, external LEDs you attach to the arms, legs, and horn.
Control Light-Emitting Diodes (LEDs) with two colors. The red-blue LEDs that come with the Quirkbot kits are such LEDs. To use this node connect the LEDs to the arms, legs, or horn.
Control servo motors connected to the servo motor backpack. Servo motors have an arm that can move to a specific position. Maximum movement is a little less than half a rotation, about 120 - 180 degrees, depending on the motor.
For controlling continuously rotating servo motors. These types of motors, sometimes referred to as "360 servos," have two things you can control: the speed
of the rotation, and the direction
of the rotation. This is unlike the other servo motors, where you can tell the motor to move its arm to a specific location.
Creates a simple tone and sends it to a physical output pin on the Quirkbot. This can be used with the DIY buzzer backpack or by connecting a small speaker or piezo element to the Quirkbot.
Makes the Quirkbot act like an external USB keyboard. When connected to the computer, it can send key presses from a defined key.
Makes the Quirkbot act like an external USB keyboard. When connected to the computer, it can send a sequence of key presses. The sequence can be sent from, for example, a List node.
Control physical outputs of the Quirkbot. Set a voltage between 0 volts and the battery voltage (3.2 - 4.2V). The node is using pulse-width modulation (PWM) and can be used on any physical place on the Quirkbot. The pads on the arms, legs, and horn are protected with current limiting resistors, but if using the backpack outputs be careful not to create a short circuit that can damage the Quirkbot.