12Blocks
Welcome | Contents | Getting Started | Reference | Hardware | FAQ | Buy
Blog | Forum
Overview | Editor Interface | Editor Dialogs | Advanced | Language | Blocks

Index | Arduino | Aseba | BS2 | NXT | PICAXE | Propeller | RPi

Block Reference:Arduino

CONTROL | GRAPHICS | SOUND | MOTION | SENSE | VARS | INTERFACE | FUNCTIONS | PINS

TabSectionNameDetail
control on <event>run a set of blocks when something happens
1 parameter:
EVENT: condition which starts this stack of blocks
basic startstart running a stack of blocks
repeatrun the inner blocks forever
repeat <number> timesrun the inner blocks a number of times
1 parameter:
NUMBER: number of times to loop
repeat <index variable> from <start> to <end> step <step>run the inner blocks with an index variable
4 parameters:
INDEX VARIABLE: variable name whose value ranges from the start to the end values
START: the value with which the loop will start
END: the value with which the loop will end
STEP: the amount by which the index variable will change after each cycle
repeat with <variable list> as <values>run the inner blocks with variables whose values changes over time
2 parameters:
VARIABLE LIST: variable names whose values change over time
VALUES: values the variables will take on
repeat while <condition>run the inner blocks while the condition is true
1 parameter:
CONDITION: condition that needs to be true to run the inner stacks
repeat until <condition>run the inner blocks until the condition is true
1 parameter:
CONDITION: condition that needs to be true to keep running the inner blocks
wait <duration>pause for a while
1 parameter:
DURATION: time in milliseconds
if <condition> elseruns the inner blocks if the condition is true
1 parameter:
CONDITION: when this condition is true, the inner blocks will run
switch <expression>runs the inner block whose value matches the condition
1 parameter:
EXPRESSION: expression to switch on
*MATCH*: when this matches the expression, the inner blocks will run
*Right click on block to access Properties for custom parameters
<comment>document your code with text, a schematic or an image
1 parameter:
COMMENT: comment which explains your code
advanced <first value> <comparer> <comment>condition block for if and repeat blocks
3 parameters:
FIRST VALUE:
COMPARER: compare type
COMMENT:
break out of repeatbreak out of repeat loop and continue with the following block
continue to start of repeatcontinue to start of repeat loop
stopstop the program
constant:<constants>assign names to numbers that won't change during the program
1 parameter:
CONSTANTS: comma separated list of names and their values
<code>inline programming code written in the device's language
1 parameter:
CODE: textual representation of code to inline into the program
state when in state <state name>run a set of blocks when the state machine matches this state
1 parameter:
STATE NAME: name of the state assigned to this stack of blocks
run state machine <name of state machine>run a state machine that manage program behavior using a state variable
1 parameter:
NAME OF STATE MACHINE: variable to use for storing machine's state
set state to <state name>set the state of the state machine
1 parameter:
STATE NAME: the state machine's new state
event when <condition>run a set of blocks when a condition is true
1 parameter:
CONDITION: condition which starts this stack of blocks
task <task name>group a set of blocks into a named task
1 parameter:
TASK NAME: name of task associated with this stack of blocks
start task <task name>start a named task and continue right away
1 parameter:
TASK NAME: task to run
start task <task name> and waitrun a named task and wait for it to finish before continuing
1 parameter:
TASK NAME: task to run
graphics print <string> to (<x>,<y>)print text to a location on the screen
3 parameters:
STRING: text to print
X: x position of cursor
Y: y position of cursor
draw background <background>print text to a location on the screen
1 parameter:
BACKGROUND: text to print
draw <sprite> to (<x>,<y>)print text to a location on the screen
3 parameters:
SPRITE: text to print
X: x position of cursor
Y: y position of cursor
sound play synthesized song <sound>play a synthesizer file
1 parameter:
SOUND: name of hmus file to play
stop playing song/effectstop playing sounds on the synthesizer
play sound effect <sound>play a sound effect file
1 parameter:
SOUND: name of hsfx file to play
play score <score>play a score of music notes as tones
1 parameter:
SCORE: score to play
pluck score <score>play a score of music notes as plucked notes
1 parameter:
SCORE: score to play
set pluck volume to <volume> tempo to <tempo> sustain to <sustain>set the parameters of how plucked music sounds
3 parameters:
VOLUME: volume to pluck at
TEMPO: tempo of plucking
SUSTAIN: sustain of pluck
play wav file <sound> at volume <volume>play a wav file
2 parameters:
SOUND: name of wav file to play
VOLUME: volume to play file at
record sound for <duration> msrecord a sound to memory
1 parameter:
DURATION: milliseconds to record sound
play recorded sound at volume <volume>play back recorded sound from memory
1 parameter:
VOLUME: volume to play sound at
read microphonesense the sound level with the microphone
read microphone amplitudesense the overall amplitude with the microphone
read microphone frequencysense the dominant frequency of sound with the microphone
play tone <frequency> for <duration> msplay a tone of music
2 parameters:
FREQUENCY: frequency of tone
DURATION: milliseconds to play tone
set tone volume to <volume>set how loud tones will be played
1 parameter:
VOLUME: volume to play tone at
speak <speech>speak text using a speech synthesizer
1 parameter:
SPEECH: text to say
speak file <speech>speak sounds specified in a file
1 parameter:
SPEECH: text to say
spell <speech>spell text with a speech synthesizer
1 parameter:
SPEECH: text to say
set speech volume to <volume>set how loud speech will be spoken
1 parameter:
VOLUME: volume to use for speech
speech parameters <glottal pitch>,<vibrato pitch>,<vibrato rate>,<pace>set the parameters of the speech synthesizer
4 parameters:
GLOTTAL PITCH: voice pitch, 100=110hz
VIBRATO PITCH: voice vibrato pitch, 48=+/- half octave swing
VIBRATO RATE: voice vibrato rate, 52=4Hz
PACE: rate at which word is spoken
set speaker <speaker> to pitch <base>Assign a base pitch to speaker number
2 parameters:
SPEAKER:
BASE:
motionmove move <amount> mm <turn-ratio>move a distance with a turning ratio
2 parameters:
AMOUNT: amount to drive robot in mm, negative to reverse
TURN-RATIO: ratio of left and right motor speeds that affects how the robot will turn while moving
turn <degrees> deg <direction>turn an amount in a direction
2 parameters:
DEGREES: degree to turn robot, negative to reverse
DIRECTION: which way to turn the robot, negative to turn left
move <amount> mm <turn-ratio> in <time> msecmove a distance with a turning ratio in a time
3 parameters:
AMOUNT: amount to drive robot in mm, negative to reverse
TURN-RATIO: ratio of left and right motor speeds that affects how the robot will turn while moving
TIME: milliseconds
turn <degrees> deg <direction> in <time> msecturn an amount in a direction in a time
3 parameters:
DEGREES: degree to turn robot, negative to reverse
DIRECTION: which way to turn the robot, negative to turn left
TIME: milliseconds
set left motor speed to <left> and right to <right>set the speed of the drive motors; the motors will maintain this speed until the next move block is run
2 parameters:
LEFT: speed for the left motor
RIGHT: speed for the right motor
set finish move mode to <action>set what should happen when move and turn blocks finish running
1 parameter:
ACTION:
set cruise speed <speed at which robot will turn/move>set the speed of the move and turn blocks
1 parameter:
SPEED AT WHICH ROBOT WILL TURN/MOVE:
configure move with <move>,<turn>set scale factor for robot move/turn blocks
2 parameters:
MOVE: amount robot will move, higher numbers move further
TURN: amount robot will turn, higher numbers turn further
configure motor with <zerol>,<zeror>,<gainl>,<gainr>,<gainl>,<gainr>set motor offset and scale parameters
6 parameters:
ZEROL: zero offset for left motor
ZEROR: zero offset for left motor
GAINL: +gain for left motor
GAINR: +gain for right motor
GAINL: -gain for left motor
GAINR: -gain for right motor
servos set servo <pin> to <position>set a servo's position
2 parameters:
PIN: pin number of servo
POSITION: target position for servo
move servo <pin> to <position>% over <time> msecramp a servo's position over time
3 parameters:
PIN: pin number of servo
POSITION: target position for servo, from -30 to 130
TIME: milliseconds to ramp the servo to the new position
ramp servo <pin> to <position>% over <time>ramp a servo's position over time while running other blocks
3 parameters:
PIN: pin number of servo
POSITION: target position for servo, from -30 to 130
TIME: milliseconds to ramp the servo to the new position
idle servo <pin>idle a servo- don't power it
1 parameter:
PIN: pin number of servo
set gripper <shoulder>,<hand> in <time> msecset gripper
3 parameters:
SHOULDER: position
HAND: position
TIME: position
sense IR distance on <pin>sense distance with an IR/LED
1 parameter:
PIN: pin number of the IR/LED
ultrasound distance on <port>sense distance with ultrasound sensor
1 parameter:
PORT: port of the sensor
brightness on <pin>sense light level with QTI sensor
1 parameter:
PIN: pin number of the QTI sensor
read encoder <side>read number of encoder pulses
1 parameter:
SIDE: side to measure
read speed <side>read speed of encoder pulses
1 parameter:
SIDE: side to measure
read line <shoulder>set gripper
1 parameter:
SHOULDER: position
read pingset gripper
read buttonset gripper
read batteryset gripper
read micset gripper
mouse mouseXread the x position of the mouse
mouseYread the y position of the mouse
mouseZread the z position of the mouse
set mouse to (0,0,0)reset x,y and z
mouse button downdetermine if the mouse button was clicked
key key <key> presseddetermine if a keyboard key is pressed
1 parameter:
KEY: key to test
8031 read adc on pin <data out pin>sense the adc's value
1 parameter:
DATA OUT PIN: data out pin followed sequentially by the clock pin and the chip select pin.
read 10 bit adc on pin <adc>sense the adc's 10 bit value
1 parameter:
ADC: adc pin
time reset timerreset the internal timer
elapsed timesense how much time has passed since the last reset
varsvariables set <variable> to <value>set a variable to a value
2 parameters:
VARIABLE: variable to set
VALUE: new value for variable
change <variable> by <amount>change a variable's value
2 parameters:
VARIABLE: variable to change
AMOUNT: amount added to variable
set bit <bit> of <variable> to <new bit value>set a bit
3 parameters:
BIT: bit to set
VARIABLE: variable to modify
NEW BIT VALUE: bit value
get bit <bit> of <variable>get a bit
2 parameters:
BIT: bit to get
VARIABLE: variable to inspect
random(<max>)return a random number between 0 and the specified maximum
1 parameter:
MAX:
set <variable> to address of <value>get pointer to a variable
2 parameters:
VARIABLE: pointer
VALUE: pointee
arrays set <array>[<index>] to <value>set an array's item to a value
3 parameters:
ARRAY: array to set
INDEX: index of array item to set
VALUE: new value for array item
change <array>[<index>] by <amount>change an array's item
3 parameters:
ARRAY: array to change
INDEX: index of array item to change
AMOUNT: amount added to array item
get <array>[<index>]get an array's item
2 parameters:
ARRAY: array to retrieve
INDEX: index of array item to retrieve
strings set <string> to <string>copy text into the string variable
2 parameters:
STRING: string to modify
STRING: text to assign
set <string> to value <new value>copy the value as text into the string variable
2 parameters:
STRING: string
NEW VALUE: value to add
string <first> equals <second>determine if the two strings are equal
2 parameters:
FIRST: first text/string to compare
SECOND: second text/string to compare
lowercase <text>return the lowercase of the string
1 parameter:
TEXT: string to modify
uppercase <text>return the uppercase of the string
1 parameter:
TEXT: string to modify
capitalize <text>capitalize the string
1 parameter:
TEXT: string to modify
reverse <text>reverse the letters of the string
1 parameter:
TEXT: string to modify
make <count> copies of <text>return a number of copies of the string
2 parameters:
COUNT: number of copies to make
TEXT: string to modify
trim <text>trim the string
1 parameter:
TEXT: string to modify
pad <text> to length <length> with <pad>pad string with a string
3 parameters:
TEXT: string to modify
LENGTH: length to pad to
PAD: text/string to pad with
replace <replacee> with <replacer> in <text>replace text in a string with another text
3 parameters:
REPLACEE: old text
REPLACER: new text
TEXT: string to modify
join <new text> to <text>join one string onto another
2 parameters:
NEW TEXT: text/string to add
TEXT: string join to
put <item> split of <text to split> into <result>split text from a string and put a specified item into another string
3 parameters:
ITEM: item of split
TEXT TO SPLIT: text/string to split
RESULT: result string
join <new byte> to <text>join a byte to a string
2 parameters:
NEW BYTE: byte to add
TEXT: string join to
get character <text>(<index>)retrieve an indexed character
2 parameters:
TEXT: text/string from which to get a character
INDEX: index
copy substring from <text> starting at <start> for <count> to <output>copy a substring from a string to another string
4 parameters:
TEXT: text/string from which to make substring
START: starting index
COUNT: characters to copy
OUTPUT: output string
copy string beginning with <begin> in <text> starting at <start> to <output>copy a string that begins with a specified text to another string
4 parameters:
BEGIN: text/string to find
TEXT: text/string to search in
START: starting index
OUTPUT: output string
find index of string <string> in <text> starting at <start>find where a string matches
3 parameters:
STRING: string to find
TEXT: text/string to search
START: starting index
find first index of <character> in <text> starting at <start>find where a character matches
3 parameters:
CHARACTER: character to find
TEXT: text/string to search
START: starting index
find last index of character <character> in <text> starting at <start>find the last occurance of a character
3 parameters:
CHARACTER: character to find
TEXT: text/string to search
START: starting index
length of <text>calculate the length of the string
1 parameter:
TEXT: text/string to count
convert <text> to a number in base <base>convert the numeric value in a string into an integer
2 parameters:
TEXT: text/string to search
BASE: use 10 to convert to decimal
interfacegeneral program infodisplay info about variables, arrays and imports. Ctrl-click on imported files to open them
value viewerdisplay a table listing variables and their values
graphdisplay a graph of variable values over time
logic levelsdisplay a graph of logic levels over time
pin activitydisplay a representation of the chip with live IO pin logic levels
videodisplay video from device
terminal terminaldisplay a terminal for text input and output
send text <text>send text to the terminal
1 parameter:
TEXT: text to send
send value <value>send a value to the terminal
1 parameter:
VALUE: value to send
send <text> <value>send text and colored number to the terminal then clear end of line
2 parameters:
TEXT: text to send
VALUE: value to send
send <command>clear to endof line
1 parameter:
COMMAND: command to send
set position <x>,<y>set the terminal's position
2 parameters:
X: x position of cursor
Y: y position of cursor
set color <color>set terminal text color
1 parameter:
COLOR: color of text
receive text into <string>receive text from the terminal and store in a string
1 parameter:
STRING: string into which to store received text
receive numberreceive a number from the terminal
receive bytereceive a byte from the terminal
received datatest if the terminal has sent something
controls backgrounddisplay an image on which other interface blocks can be docked
textboxdisplay and change a variable's value with a textbox
meterdisplay a variable's value in a meter
switchdisplay and change a variable's value as a switch
joystickuse a joystick to control two variables
savesave to file
advanced bird's eye view <sim>display a bird's eye view of a robot environment and simulate the robot's movements
1 parameter:
SIM: world
simulatordisplay a 3d view of a robot environment and simulate the robot's movements
swarm <config>swarm $
1 parameter:
CONFIG: swarm configuration
integrate with skypeattach to the skype application to allow variable values to be changed and monitored remotely
integrate with xmlrpcstart a server that supports xmlrpc communication to change and monitor variable values
integrate with rosstart a ros node to support monitoring and changing variables using the robot operation system
find fiducial marker <function>communicate with a fiducial image server to recognize where objects are with vision
1 parameter:
FUNCTION:
functions <name> (<arguments>) locals:<local variables>group a set of blocks to a named function, you can specify arguments passed into the function as well as local variables
3 parameters:
NAME: name for this function
ARGUMENTS: arguments passed to this function
LOCAL VARIABLES: names of variables that are only used in this function
return <return value>return a value from a function
1 parameter:
RETURN VALUE: value to return
synchronize functions <synchronize>create a set of blocks that will run functions at exact times
1 parameter:
SYNCHRONIZE:
at <time> do <task name>(<task length>)at a set time, run a named task
3 parameters:
TIME: time in msec
TASK NAME: task to run
TASK LENGTH: length of task
pinsin count edges on pin <pin> for <duration>count the number of rising edges on a pin
2 parameters:
PIN: pin number to count edges on
DURATION: milliseconds during which edges are counted
measure frequency on pin <pin> for <duration>measure the frequency on a pin
2 parameters:
PIN: pin number to measure frequency on
DURATION: milliseconds during which frequency is measured
measure pulse on pin <pin> at state <state>measure the duration of a pulse on a pin
2 parameters:
PIN: pin number to measure pulse on
STATE: state of pin
measure pulse on pin <pin> at state <state> with length <state>measure the duration of a pulse on a pin
3 parameters:
PIN: pin number to measure pulse on
STATE: state of pin
STATE: maximum pulse length in usec
pin <pin>read the state of an IO pin
1 parameter:
PIN: pin on which state is measured
duration of discharge on pin <pin>measure the time until a pin's state changes
1 parameter:
PIN: pin which is tested
shift data in from pin <pin> mode <mode>shift in 8 bits of data using 3 pins
2 parameters:
PIN: pin on which data is shifted in, followed sequentially by the clock pin and then the chip select pin
MODE: mode: 0 = MSBPRE 0 Data is msb-first; sample bits before clock pulse 1 = LSBPRE 1 Data is lsb-first; sample bits before clock pulse 2 = MSBPOST 2 Data is msb-first; sample bits after clock pulse 3 = LSBPOST 3 Data is lsb-first; sample bits after clock pulse
serial in from pin <pin> mode:(<baud>,<mode>,<bits>)read data using the serial protocol
4 parameters:
PIN: pin from which data is received
BAUD: rate at which data is received
MODE: mode: 0=inverted(normally low) 1=non-inverted(normally high)
BITS: number of bits to receive
read i2c on pin <pin> and reply with <ackbit>read byte using i2c protocol and acknowledge
2 parameters:
PIN: pin to transmit on
ACKBIT: acknowledge bit
read <bytes> bytes from <address> into <data>read data from an i2c eeprom
3 parameters:
BYTES: bytes to write
ADDRESS: eeprom address
DATA: data array
read adc on pin <pin>sense the adc's value
1 parameter:
PIN: pin to measure
out output frequency <frequency> on pin <pin>continually output a frequency on a pin
2 parameters:
FREQUENCY: frequency to output in Hz
PIN: pin for output
output frequency <frequency> on pin <pin> for <duration>output a frequency on a pin for a duration
3 parameters:
FREQUENCY: frequency to output in Hz
PIN: pin for output
DURATION: milliseconds for output
set pin <pin> highset a pin high
1 parameter:
PIN: pin to set high
set pin <pin> lowset a pin low
1 parameter:
PIN: pin to set low
toggle pin <pin>change a pin's state from high to low/low to high
1 parameter:
PIN: pin to change
configure pin <pin> as <mode>set a pin's mode
2 parameters:
PIN: pin to change
MODE: pin
output pulse length <duration>uSec on pin <pin>output a pulse
2 parameters:
DURATION: microseconds to output pulse
PIN: pin to output
output pwm <duty> on pin <pin>output a pulse width modulated signal
2 parameters:
DUTY: duty cycle, form 0 to 256
PIN: pin to output
output pwm <duty> on pin <pin> for <duration>output a pulse width modulated signal
3 parameters:
DUTY: duty cycle, form 0 to 256
PIN: pin to output
DURATION: milliseconds for output
shift out data <data> on pin <pin> mode <mode>shift data to a device
3 parameters:
DATA: value to shift out
PIN: pin to output to
MODE: mode
send serial data <data> on pin <pin> mode:(<baud>,<mode>,<bits>)send data with the serial protocol
5 parameters:
DATA: value to transmit
PIN: pin to transmit on
BAUD: rate at which data is transmitted
MODE: mode: 0=inverted(normally low) 1=non-inverted(normally high)
BITS: bits to transmit
initialize i2c device on <pin>initialize the i2c device
1 parameter:
PIN: i2c scl pin
send start i2c token on <pin>send a start i2c token
1 parameter:
PIN: i2c scl pin
write i2c data <data> to pin <pin>write data with the i2c protocol
2 parameters:
DATA: value to transmit
PIN: pin to transmit on
send stop i2c token on <pin>send a stop i2c token
1 parameter:
PIN: i2c scl pin
write <bytes> bytes of <data> to <address>write data to an i2c eeprom
3 parameters:
BYTES: bytes to write
DATA: data array
ADDRESS: eeprom address
share array: <arrays>share arrays with 12Blocks to upload/download data
1 parameter:
ARRAYS: type a quoted, commas separated list of array names
quickly sample the IO pinsquickly sample the IO pins
analog out <duty> to pin <pin>output a pulse width modulated signal
2 parameters:
DUTY: duty cycle, from 0 to 256
PIN: pin to output