# 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 When [ Run] clicked Run the code. ### Audio Play [Select folder ▾] [Select file ▾] audio with ([80]) volume Select and play audio at set volume. Play [Select folder ▾] ([audio]) . [mp3 ▾] audio with ([80]) volume Enter music file name to play. Stop audio Stop the audio currently playing. Record for ([5]) seconds and save to [Select folder ▾] ([audio]) . [mp3 ▾] 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. ``` Search Wikipedia for ([Robot]) (Internet!) Search Wikipedia with the given keyword. *returns a value* [Seoul ▾] Search for comprehensive weather information (Internet!) Search for comprehensive weather information in a specific area. *returns a value* [Seoul ▾] Search for [today ▾] weather information [forecast ▾] (Internet!) Search for weather information in a specific area. *returns a value* [newsflash ▾] Search for [topic ▾] news (Internet!) Retrieve search results with news keywords. *returns a value* ### Device Set right eye to ([0]) ([0]) ([0]) , left eye to ([0]) ([0]) ([0]) Turn on eye LED Set right eye to ([item ▾]) , left eye to ([item ▾]) Turn on eye LED with a color variable. Check adapter Check adapter connection status. *returns a value* Check battery Check battery status. *returns a value* Check system message Check system messages. *returns a value* Check for human presence Detect presence of people. *returns a value* Check touch Detect touch. *returns a value* Check button Check button status. *returns a value* ### Motion Get motion list Retrieve list of available motions. *returns a value* Get list of motions I made Retrieve list of custom motions. *returns a value* Run motion [Select motion ▾] ([1]) times Run a chosen motion a specified number of times. Run motion ([wave1]) ([1]) times Run an entered motion a specified number of times. Run motion I made ([my motion]) ([1]) times Run one of my motions. Initialize motion Initialize motion settings. Move [Right foot[0] ▾] motor to ([0]) degrees Move a specified motor to a certain degrees. Set [Right foot[0] ▾] motor speed to ([40]) Set the speed of the motor. Set [Right foot[0] ▾] motor acceleration to ([0]) Set the acceleration of the motor. Move all motors to angles ([0,0,0,0,0,0,0,0,0,0]) over ([1000]) ms Moves all motors to a certain degrees by the specified time. ### Display Set screen font size to ([30]) Set the font size on the screen. Save ([Hello]) to screen at ([0]) ([0]) Save text to the screen. Save image [Select folder ▾] [Select file ▾] to screen Save the selected image to the screen. Save image [Select folder ▾] ([image]) . [jpg ▾] to screen Save the given image to the screen. Save image ([item ▾]) to screen Save an image variable to the screen. Save [Fill ▾] rectangle to screen at ([0]) ([0]) , ([0]) ([0]) Save a rectangle to the screen. Save [Fill ▾] ellipse to screen at ([0]) ([0]) , ([0]) ([0]) Save an ellipse to the screen. Save line to screen at ([0]) ([0]) , ([0]) ([0]) Save a line to the screen. Invert screen Invert the colors on the screen. Show screen Show what was saved to the screen. Clear screen Clear the screen. ### Speech Listen for up to ([5]) seconds and convert to text 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* Save ([Hello]) with [Male 1 ▾] voice to [Select folder ▾] ([audio]) . [mp3 ▾] Make speech on the robot and save it to a file. Korean and English are detected automatically. Say ([Hello]) with [Male 1 ▾] voice at ([80]) volume Make speech on the robot and say it. Korean and English are detected automatically. Choose chat model [TheMaker KO ▾] 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 Start LLM server. Say ([Hello]) to AI, as role (값) Send text to the LLM server and get a reply. The role sets how the robot should answer. *returns a value* Stop LLM server Stop the LLM server. ### Vision Take a picture Capture an image. *returns a value* Take a picture with USB camera [cam1 ▾] 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 image file [Select folder ▾] [Select file ▾] Load a specified image file. *returns a value* Load image file [Select folder ▾] ([image]) . [jpg ▾] Load an image file. *returns a value* Create ([item ▾]) Color matte Create a blank image filled with the chosen color. *returns a value* Save image ([item ▾]) to [Select folder ▾] ([image]) . [jpg ▾] Save as an image file. Show image ([item ▾]) on the monitor Show an image variable on the monitor (IDE run panel). Show image ([item ▾]) on the device screen Show an image variable on the screen. On image ([item ▾]) , draw a rectangle at ([0]) ([0]) , ([0]) ([0]) with thickness ([2]) and color ([item ▾]) Draws a rectangle on the image. On image ([item ▾]) , draw a circle at center ([0]) ([0]) with radius ([0]) , thickness ([2]) and color ([item ▾]) Displays a circle in the image. On image ([item ▾]) , draw a line at ([0]) ([0]) , ([0]) ([0]) with thickness ([2]) and color ([item ▾]) Displays a line in the image. On image ([item ▾]) , at ([0]) ([0]) with size ([30]) and color ([item ▾]) , write ([Hello]) Display text on the image. Convert image ([item ▾]) to [cartoon ▾] style Transform image style. *returns a value* image ([item ▾]) resize to width ([100]) height ([100]) Resize the image. *returns a value* 6×8 dot picture Turns the 6×8 picture you draw by tapping dots into an image (scaled to the camera size). *returns a value* 8×4 dot picture Turns the 8×4 picture you draw by tapping dots into an image (scaled to the camera size). *returns a value* 8×8 dot picture Turns the 8×8 picture you draw by tapping dots into an image (scaled to the camera size). *returns a value* ### Recognition Find faces in image ([item ▾]) Detect and identify faces in the specified image. *returns a value* Show face ([item ▾]) in the image ([item ▾]) Show faces in the image. Get age·gender·emotion of face ([item ▾]) in image ([item ▾]) Analyze face in image(age, gender, emotion) *returns a value* Show age·gender·emotion ([item ▾]) on image ([item ▾]) Show face analysis in the image Find face ([item ▾]) landmark in the image ([item ▾]) Find face landmark in the image *returns a value* Show face landmark ([item ▾]) in the image ([item ▾]) Show face landmark in the image. Get face direction·distance in image ([item ▾]) Analyze face direction/distance in the image. *returns a value* Show face direction·distance ([item ▾]) on image ([item ▾]) Show face direction/distance in the image Face dictionary Get the list of names in the face dictionary. *returns a value* Train face ([item ▾]) in image ([item ▾]) as name ([pibo]) in the face dictionary Train face from image. Delete name ([pibo]) from the face dictionary Delete a specific face from training faces. Find the name of face ([item ▾]) in image ([item ▾]) in the face dictionary Recognize who faces are in an image. *returns a value* Save the face dictionary to [Select folder ▾] ([facedb]) Save face training data to file. Load the face dictionary from [Select folder ▾] ([facedb]) Load face training data from file. Load Object detection model [Select folder ▾] ([job1]) .onnx 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 ([item ▾]) Find objects in the image. *returns a value* Find objects in the image ([item ▾]) (original values) Find objects in the image. (RAW) *returns a value* Show objects ([item ▾]) in the image ([item ▾]) Show objects in the image. Find QR in the image ([item ▾]) Find QR in the image. *returns a value* Find QR in the image ([item ▾]) (original values) Find QR in the image. (RAW) *returns a value* Show QR ([item ▾]) in the image ([item ▾]) Show QR codes in the image. Detect poses in image ([item ▾]) Identify and analyze human poses in the specified image. *returns a value* Show pose data ([item ▾]) in the image ([item ▾]) Show pose data in the image. Get [pose analysis ▾] from pose data ([item ▾]) Evaluate and interpret pose data from the image and save the results. *returns a value* Load Hand gesture model [gesture_recognizer ▾] Load Hand gesture model. Load Hand gesture model [Select folder ▾] ([gesture_recognizer]) .task Load Hand gesture model Check hand gesture in the image ([item ▾]) Recognize Hand gesture in the image. *returns a value* Show hand gesture ([item ▾]) in the image ([item ▾]) Show hand gesture in the image. Find ([5]) cm markers in image ([item ▾]) Detect Marker in the specified image. *returns a value* Show marker ([item ▾]) in the image ([item ▾]) Show marker in the image. Load classification model [Select folder ▾] ([model name]) Load a model you taught and saved in the Classifier. Folder mymodel, then the model name. (image, hand, face, pose) Classify image ([item ▾]) with the classification model 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* Show the classification result on image ([item ▾]) 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 Delay for ([1]) seconds Pause the process for a specified duration of seconds. Get time data Retrieve the current time value. *returns a value* Get current time Obtain the current time. *returns a value* Check if ( ) is included in ( ) Verify if an element is included in a list or array. *returns a value* Get value of key ([Key name]) from dictionary ([my_dict ▾]) Retrieve the value associated with a specific key in a dictionary. *returns a value* Append { ([Key name]) : ( ) } to dictionary ([my_dict ▾]) Add a new key-value pair to an existing dictionary. set [my_dict ▾] to (Create empty dictionary) Sets this variable to be equal to the input. Set range [ ([0]) : ([0]) , ([0]) : ([0]) ] of ([item ▾]) to ([item ▾]) Set the values of the specified range in the array. Check if ([Path]) [File ▾] exists Confirm the existence of a file or directory. *returns a value* Convert ([1]) to text Change a variable's type to String. *returns a value* Convert ([1]) to [Integer ▾] number Convert a variable to a specific numeric type. (Integer or Float) *returns a value* Get angle of ([item ▾]) - ([item ▾]) - ([item ▾]) 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 forever ? Repeats the blocks inside until you stop. ### Easy · Motion do motion Hello Goes on to the next block when the motion is done. do my motion (none) Motions you saved in Tools [Motion]. ### Easy · Speak · Sound play sound Ding Goes on to the next block when the sound is done. play note Do Goes on to the next block when the sound is done. play music (none) Starts the music and goes on to the next block. stop music Stops the music that is playing. ### Easy · Screen show smile on device screen Shows the picture you chose on the screen. show (“ Hello ”) on device screen Shows text or a number on the device screen. clear device screen Clears the device screen. ### Easy · Sensors head touched? Checks right now. Use it inside forever to wait for it. *returns a value* someone there? Checks right now. Use it inside forever to wait for it. *returns a value* ### Easy · Camera take a photo as is and show on monitor screen Put it in forever to see it like a video. ### Easy · AI Eyes camera sees a face ? Takes one camera picture and looks. *returns a value* hand is thumbs up ? Takes one camera picture and looks. *returns a value* face is smiling ? Takes one camera picture and looks. *returns a value*