# Block coding
piBo Coding uses Blockly for block coding. Besides the standard blocks there are piBo blocks that call
the **openpibo** Python package. The [Python code] button shows the Python code your blocks make.
```{note}
Everything runs **inside piBo**. Only the [Collect] category needs the internet, and it is only in the Korean edition.
```
## Categories
**Standard Blockly blocks** — Hover over a block to see what it does.
| Category | Blocks |
|---|---|
| Logic | 7 |
| Loops | 5 |
| Math | 13 |
| Text | 15 |
| Lists | 12 |
| Color | 4 |
| Variables | appear when you make one |
| Functions | appear when you make one |
**piBo blocks**
| Category | Blocks |
|---|---|
| Start | 1 |
| Audio | 4 |
| Collect | 4 |
| Device | 8 |
| Motion | 10 |
| Display | 11 |
| Speech | 7 |
| Vision | 17 |
| Recognition | 33 |
| Utilities | 12 |
**Easy blocks** — 16 beginner blocks shown when you choose [Easy] in [Easy | All] on the editor bar (see 'Easy blocks' below)
## piBo blocks
### Start
Run the code.
### Audio
Select and play audio at set volume.
Enter music file name to play.
Stop the audio currently playing.
Record for a set time and save as a file.
### Collect
```{note}
Korean edition only (Korean weather regions and a Korean news feed). The Global edition does not have this category.
```
(Internet!) Search Wikipedia with the given keyword. *returns a value*
(Internet!) Search for comprehensive weather information in a specific area. *returns a value*
(Internet!) Search for weather information in a specific area. *returns a value*
(Internet!) Retrieve search results with news keywords. *returns a value*
### Device
Turn on eye LED
Turn on eye LED with a color variable.
Check adapter connection status. *returns a value*
Check battery status. *returns a value*
Check system messages. *returns a value*
Detect presence of people. *returns a value*
Detect touch. *returns a value*
Check button status. *returns a value*
### Motion
Retrieve list of available motions. *returns a value*
Retrieve list of custom motions. *returns a value*
Run a chosen motion a specified number of times.
Run an entered motion a specified number of times.
Run one of my motions.
Initialize motion settings.
Move a specified motor to a certain degrees.
Set the speed of the motor.
Set the acceleration of the motor.
Moves all motors to a certain degrees by the specified time.
### Display
Set the font size on the screen.
Save text to the screen.
Save the selected image to the screen.
Save the given image to the screen.
Save an image variable to the screen.
Save a rectangle to the screen.
Save an ellipse to the screen.
Save a line to the screen.
Invert the colors on the screen.
Show what was saved to the screen.
Clear the screen.
### Speech
Listen with the robot microphone and turn speech into text when you stop talking. Runs on the robot; Korean and English are detected automatically. The first call takes a few extra seconds to get ready. *returns a value*
Make speech on the robot and save it to a file. Korean and English are detected automatically.
Make speech on the robot and say it. Korean and English are detected automatically.
Choose the model before starting the chat server. Without it, the general model starts.
There are three models: **General** (Korean and English, no tools — currently Google Gemma3 1B), **TheMaker KO** (Korean only, short and polite) and **TheMaker EN** (English only). Both TheMaker models learned tools (light, look, move), but the [Say … to AI] block is text only — if the model tries to answer with a tool, that part is dropped and you get only the text. This block only chooses, so put it **before [Start LLM server]**. Without it the general model starts, and the choice lasts only in that program. TheMaker already has its speaking style inside the model, so it works best with the role of the [Say … to AI] block **left empty**. Only one model runs at a time.
Start LLM server.
Send text to the LLM server and get a reply. The role sets how the robot should answer. *returns a value*
Stop the LLM server.
### Vision
Capture an image. *returns a value*
Takes a picture with a USB camera (any camera that supports V4L2). cam1 and cam2 follow the USB port order (same names as the camera picker in Tools and Classifier). For the board camera, use the [Take a picture] block. *returns a value*
Load a specified image file. *returns a value*
Load an image file. *returns a value*
Create a blank image filled with the chosen color. *returns a value*
Save as an image file.
Show an image variable on the monitor (IDE run panel).
Show an image variable on the screen.
Draws a rectangle on the image.
Displays a circle in the image.
Displays a line in the image.
Display text on the image.
Transform image style. *returns a value*
Resize the image. *returns a value*
Turns the 6×8 picture you draw by tapping dots into an image (scaled to the camera size). *returns a value*
Turns the 8×4 picture you draw by tapping dots into an image (scaled to the camera size). *returns a value*
Turns the 8×8 picture you draw by tapping dots into an image (scaled to the camera size). *returns a value*
### Recognition
Detect and identify faces in the specified image. *returns a value*
Show faces in the image.
Analyze face in image(age, gender, emotion) *returns a value*
Show face analysis in the image
Find face landmark in the image *returns a value*
Show face landmark in the image.
Analyze face direction/distance in the image. *returns a value*
Show face direction/distance in the image
Get the list of names in the face dictionary. *returns a value*
Train face from image.
Delete a specific face from training faces.
Recognize who faces are in an image. *returns a value*
Save face training data to file.
Load face training data from file.
Loads an object detection model. Type the name of a model file from easydetect (such as job1.onnx) without .onnx. Its class names and threshold are inside the file.
Find objects in the image. *returns a value*
Find objects in the image. (RAW) *returns a value*
Show objects in the image.
Find QR in the image. *returns a value*
Find QR in the image. (RAW) *returns a value*
Show QR codes in the image.
Identify and analyze human poses in the specified image. *returns a value*
Show pose data in the image.
Evaluate and interpret pose data from the image and save the results. *returns a value*
Load Hand gesture model.
Load Hand gesture model
Recognize Hand gesture in the image. *returns a value*
Show hand gesture in the image.
Detect Marker in the specified image. *returns a value*
Show marker in the image.
Load a model you taught and saved in the Classifier. Folder mymodel, then the model name. (image, hand, face, pose)
Classify the image with the loaded classification model and return the best matching name. Hand, face and pose models return empty text when no hand, face or body is in view. *returns a value*
Draws what the last [Classify image … with the classification model] saw on that image: points and bones for hand and pose, points for face, plus the class name and probability.
### Utilities
Pause the process for a specified duration of seconds.
Retrieve the current time value. *returns a value*
Obtain the current time. *returns a value*
Verify if an element is included in a list or array. *returns a value*
Retrieve the value associated with a specific key in a dictionary. *returns a value*
Add a new key-value pair to an existing dictionary.
Sets this variable to be equal to the input.
Set the values of the specified range in the array.
Confirm the existence of a file or directory. *returns a value*
Change a variable's type to String. *returns a value*
Convert a variable to a specific numeric type. (Integer or Float) *returns a value*
Get angle *returns a value*
## Easy blocks
Choose [Easy] in **[Easy | All]** on the editor bar to get fewer categories and the blocks below. They hide the camera, variables and images inside the block so you only pick. The Easy toolbox also has basic blocks such as [if], [repeat], lights and speak, and you can mix Easy and All blocks in one program.
### Easy · Start · Repeat
Repeats the blocks inside until you stop.
### Easy · Motion
Goes on to the next block when the motion is done.
Motions you saved in Tools [Motion].
### Easy · Speak · Sound
Goes on to the next block when the sound is done.
Goes on to the next block when the sound is done.
Starts the music and goes on to the next block.
Stops the music that is playing.
### Easy · Screen
Shows the picture you chose on the screen.
Shows text or a number on the device screen.
Clears the device screen.
### Easy · Sensors
Checks right now. Use it inside forever to wait for it. *returns a value*
Checks right now. Use it inside forever to wait for it. *returns a value*
### Easy · Camera
Put it in forever to see it like a video.
### Easy · AI Eyes
Takes one camera picture and looks. *returns a value*
Takes one camera picture and looks. *returns a value*
Takes one camera picture and looks. *returns a value*