Skip to content

Piobot ​

Instance declaration ​

When you add a Piobot block to the workspace, the following instance declaration is automatically inserted into the Python code:

python
pio = Pio(0)
# When there are multiple instances
pio_1 = Pio(1)

Parameters ​

NameKindDescriptionRange / TypeDefault
indexDropdown optionInstance number (starting from 0)Integer 0 or greater0

Set wheel speed ​

Sets the wheel speed. The wheel speed ranges from -100 to 100.

set_wheel_speed

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionWheel to controlleft, right, both-
speedInput (block)Wheel speedInteger -100 to 100, 0: stop-

Python ​

python
pio = Pio(0)

pio.set_wheel_speed('both', 50)

Move a distance ​

Moves the specified distance at the current wheel speed.
If the wheel speed has not been set, it moves forward at the default speed.
If the distance is 0, it keeps moving according to the current wheel speed.
If wait is checked, execution waits until the movement is complete.

move_distance

Parameters ​

NameKindDescriptionRange / TypeDefault
dataInput (block)Distance to moveReal number 0 or greater-
unitDropdown optionDistance unitcm, mm, inchcm
waitCheckboxWhether to wait for completionTRUE / FALSETRUE

Python ​

python
pio = Pio(0)

pio.move_distance(50, 'cm', wait=True)

Move for a time ​

Moves for the specified time at the current wheel speed.
If the wheel speed has not been set, it moves forward at the default speed.
If wait is checked, execution waits until the movement is complete.

move_time

Parameters ​

NameKindDescriptionRange / TypeDefault
dataInput (block)Time to move (seconds)Real number 0 or greater-
waitCheckboxWhether to wait for completionTRUE / FALSETRUE

Python ​

python
pio = Pio(0)

# wait = TRUE
pio.move_time(5, wait=True)
# wait = FALSE
pio.move_time(5, wait=False)

Turn in place ​

Sets the direction and angle to rotate in place.
If wait is checked, execution waits until the rotation is complete.

turn_degree

Parameters ​

NameKindDescriptionRange / TypeDefault
directionDropdown optionDirection of rotationleft, right-
dataInput (block)Angle of rotation (degrees)Real number 0 or greater-
waitCheckboxWhether to wait for completionTRUE / FALSETRUE

Python ​

python
pio = Pio(0)

# direction = "left"
pio.turn_degree('left', 90, wait=True)
# direction = "right"
pio.turn_degree('right', 90, wait=True)

Change wheel speed ​

Changes the wheel speed of Piobot.
The new wheel speed is the current wheel speed plus the speed you enter.
The newly set wheel speed is clamped to the range -100 to 100.

change_speed

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionWheel to controlleft, right, both-
speedInput (block)Amount of speed changeInteger -200 to 200-

Python ​

python
pio = Pio(0)

pio.change_wheel_speed('both', 50)

Turn turbo mode on / off ​

Turns the turbo mode of Piobot on or off.

turbo

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionTurbo mode ON / OFFon (True), off (False)TRUE

Python ​

python
pio = Pio(0)

pio.turbo(True)

Stop ​

Stops the movement of Piobot.
The speed of both wheels of Piobot is reset to 0.

stop

Parameters ​

(none)

Python ​

python
pio = Pio(0)

pio.stop()

Is the wheel moving? ​

Returns true if the wheel is moving, and false if it is stopped.

wheel_moving

Parameters ​

(none)

Python ​

python
pio = Pio(0)

pio.wheel_moving()

Move one step on the board ​

Moves one step at a time on the board as configured.

grid_move

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionDirection to moveforward, backward, left, right-

Python ​

python
pio = Pio(0)

pio.grid_move('forward')

Turn once on the board ​

Piobot rotates 90 degrees on the board in the given direction. It always waits until completion (internally wait=True is fixed).

grid_turn

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionDirection of rotationleft, right-

Python ​

python
pio = Pio(0)

# unit = "left"
pio.grid_turn('left')
# unit = "right"
pio.grid_turn('right')

Set neck rotation speed ​

Sets the rotation speed of the neck. The neck speed ranges from 1 to 6.

set_neck_speed

Parameters ​

NameKindDescriptionRange / TypeDefault
dataInput (block)Neck rotation speedInteger 1 to 64

Python ​

python
pio = Pio(0)

pio.set_neck_speed(4)

Set neck angle ​

Sets the angle the neck rotates to. The neck angle ranges from -45 to 45.

set_neck_angle

Parameters ​

NameKindDescriptionRange / TypeDefault
dataInput (block)Neck angle (degrees)Real number -45 to 45-
waitCheckboxWhether to wait for completionTRUE / FALSETRUE

Python ​

python
pio = Pio(0)

pio.set_neck_angle(15, wait=True)

Is the neck moving? ​

Returns true if the neck is moving, and false if it is stopped.

neck_moving

Parameters ​

(none)

Python ​

python
pio = Pio(0)

pio.neck_moving()

Set eye LED color ​

Sets the eye LED color of Piobot.
You can change the color of the left eye, the right eye, or both.
When you pick a color from the color preset, it is converted to a color name (an English string) for the call. (The generated code uses a color name, not R, G, B numeric values.)

set_eye_color

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionEye to controlleft, right, both-
colorDropdown optionColor preset → converted to a color name (English)black, red, yellow, green, cyan, blue, magenta, white-

Python ​

python
pio = Pio(0)

pio.set_eye_color('both', 'red')

Set eye LED color with a Color category block ​

Sets the eye LED color of Piobot using blocks from the Color category.
You can change the color of the left eye, the right eye, or both.

set_eye_color_with_block

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionEye to controlleft, right, both-
dataInput (color)An [R, G, B] arrayA Color category block or [0~255, 0~255, 0~255]-

Python ​

python
pio = Pio(0)

pio.set_eye_color('both', *Utils.color('red'))

Change eye LED color by the specified RGB ​

Changes the eye LED color of Piobot by the specified R, G, and B amounts.
You can set the color of the left eye, the right eye, or both.

change_by_rgb

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionEye to controlleft, right, both-
rInput (field)Amount of red changeInteger -255 to 2550
gInput (field)Amount of green changeInteger -255 to 2550
bInput (field)Amount of blue changeInteger -255 to 2550

Python ​

python
pio = Pio(0)

pio.change_eye_color('both', 10, 0, 0)

Set eye LED pattern ​

Sets the pattern of the eyes and specifies the color of each eye when the pattern starts.

set_eye_pattern

Parameters ​

NameKindDescriptionRange / TypeDefault
patternDropdown optionKind of patternreset, blink, dimming, rainbow-
leftDropdown optionLeft eye colordefault (black), red, yellow, green, cyan, blue, magenta, whitewhite
rightDropdown optionRight eye color(same as left)white

Python ​

python
pio = Pio(0)

pio.set_eye_pattern('dimming', 'green', 'red')

Turn off eye LED ​

Removes the color of the eyes.

turn_off

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionEye to controlleft, right, bothboth

Python ​

python
pio = Pio(0)

pio.turn_off('both')

Set sound buzz ​

Sets the buzzer sound of Piobot to the specified frequency.
The frequency range that can produce sound is 27.5 Hz to 6553.5 Hz.
If you enter a value outside this range, no buzzer sound is produced.

sound_buzz

Parameters ​

NameKindDescriptionRange / TypeDefault
hzInput (block)Frequency (Hz)Real number 27.5 to 6553.5-

Python ​

python
pio = Pio(0)

pio.sound_buzz(440)

Play a note ​

Piobot plays the specified note.

sound_note

Parameters ​

NameKindDescriptionRange / TypeDefault
noteDropdown optionNoteDo (C), Do#/Re♭ (C#), Re (D), Re#/Mi♭ (D#), Mi (E), Fa (F), Fa#/Sol♭ (F#), Sol (G), Sol#/La♭ (G#), La (A), La#/Si♭ (A#), Si (B)-
octaveDropdown optionOctave1, 2, 3, 4, 5, 6, 74

Python ​

python
pio = Pio(0)

pio.sound_note('D', 5)

Play a sound clip ​

Piobot plays a particular sound clip.
If wait is checked, execution waits until playback is complete.

sound_clip

Parameters ​

NameKindDescriptionRange / TypeDefault
clipDropdown optionSound clip name'mute', 'beep', 'beep2', 'beep3', 'siren', 'engine', 'robot', 'connect', and so on-
waitCheckboxWhether to wait for completionTRUE / FALSETRUE

Python ​

python
pio = Pio(0)

pio.sound_clip('siren', wait=True)

Play a melody ​

Piobot plays a particular melody.
If wait is checked, execution waits until playback is complete.

sound_melody

Parameters ​

NameKindDescriptionRange / TypeDefault
melodyDropdown optionMelody name'mute', 'happy', 'angry', 'sad', 'sleep', 'march', 'birthday', 'dibidibidip', 'good_job', and so on-
waitCheckboxWhether to wait for completionTRUE / FALSETRUE

Python ​

python
pio = Pio(0)

pio.sound_melody('happy', wait=True)

Sound off ​

Turns off the sound of Piobot.

sound_off

Parameters ​

(none)

Python ​

python
pio = Pio(0)

pio.sound_off()

Is a sound playing? ​

Returns true if a sound is playing, and false if it is not.

sound_playing

Parameters ​

(none)

Python ​

python
pio = Pio(0)

pio.sound_playing()

Wheel speed value ​

The speed of a particular wheel

wheel_speed

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionWheel to readleft, right-

Python ​

python
pio = Pio(0)

pio.wheel_speed('left')

Signal strength value ​

The signal strength

signal_strength

Parameters ​

(none)

Python ​

python
pio = Pio(0)

pio.signal_strength()

Battery voltage ​

The battery voltage

battery

Parameters ​

(none)

Python ​

python
pio = Pio(0)

pio.battery()

Keypad button ​

Detects the keypad button the user pressed last.

keypad

Parameters ​

NameKindDescriptionRange / TypeDefault
buttonDropdown optionButton to detectplay, move forward (forward), move backward (backward), move left (left), move right (right), action, repeat, clear-

Python ​

python
pio = Pio(0)

pio.keypad('forward')