# Block coding PiBrain Maker uses Blockly for block coding. Besides the standard blocks there are PiBrain blocks that call the **openpibo** Python package. The [Python code] button shows the Python code your blocks make. ```{note} This page is generated from the IDE toolbox (`docs/tools/gen_block_guide.py`). Each picture shows the block as it comes out of the toolbox. Everything runs **inside PiBrain**. 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) ├── Logic (7) ├── Loops (5) ├── Math (13) ├── Text (15) ├── Lists (12) ├── Colour (4) ├── Variables (appear when you make one) └── Functions (appear when you make one) PiBrain blocks ├── Start (1) ├── Audio (3) ├── Collect (4) ├── Device (7) ├── Oled (11) ├── Speech (7) ├── Vision (16) ├── Rec (36) └── Utils (12) ``` ## PiBrain 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. ### 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 Check button [SW1 ▾] Check button status. *returns a value* Turn on LEDs ([0]) ([0]) ([0]) Turn on LED Turn on LEDs with color variable ([item ▾]) Turn on LED with a color variable. Turn off LEDs Turn off LED Connect [USB0 ▾] Connect USB Device. Send (값) to USB Device Send message to USB Device. Disconnect USB Device Disconnect USB Device. ### Oled Set OLED font size to ([30]) Set the font size on the OLED display. Save ([Hello]) to OLED at ([0]) ([0]) Display text on the OLED screen. Save OLED [Select folder ▾] [Select file ▾] image Display dynamically selected image on OLED. Save OLED [Select folder ▾] ([sample]) . [jpg ▾] image Display a specified image on OLED. Save OLED ([item ▾]) image data Display a specified image data on OLED. Save [Fill ▾] rectangle to OLED at ([0]) ([0]) , ([0]) ([0]) Draw a rectangle on OLED. Save [Fill ▾] ellipse to OLED at ([0]) ([0]) , ([0]) ([0]) Draw an ellipse on OLED. Save line to OLED at ([0]) ([0]) , ([0]) ([0]) Draw a line on OLED. Invert OLED Invert colors on the OLED screen. Show OLED Display content on OLED screen. Clear OLED Clear the OLED screen. ### Speech Save ([Hello]) with [Male 1 ▾] voice to [Select folder ▾] ([tts]) . [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. Save ([Hello]) with Espeak voice to [Select folder ▾] ([tts]) . [mp3 ▾] Save text as espeak robot voice to a file. Say ([Hello]) with Espeak voice at ([80]) volume Say text with the espeak robot voice. Start LLM server Start LLM server. Respond to ([Hello]) , System prompt (값) Send text to the LLM server and get a reply. The system prompt sets how piBo should answer. *returns a value* Stop LLM server Stop the LLM server. ### Vision Take a picture Capture an image. *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. Display image variable ([item ▾]) on IDE Display an image variable in IDE. Display image variable ([item ▾]) on OLED Display an image variable in OLED. Display a rectangle with color ([item ▾]) and thickness ([2]) at coordinates ([0]) ([0]) ([0]) ([0]) of image ([item ▾]) . Draws a rectangle on the image. Display a circle with radius ([0]) , color ([item ▾]) , thickness ([2]) at coordinates ([0]) ([0]) of image ([item ▾]) . Displays a circle in the image. Display a line with color ([item ▾]) and thickness ([2]) at coordinates from ([0]) ([0]) to ([0]) ([0]) of image ([item ▾]) . Displays a line in the image. Display ([Hello]) with size ([30]) and color ([item ▾]) at coordinates ([0]) and ([0]) of image ([item ▾]) . Display text on the image. Convert image ([item ▾]) to [cartoon ▾] 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* ### Rec 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. Analyze face ([item ▾]) of image ([item ▾]) (age, gender, emotion) Analyze face in image(age, gender, emotion) *returns a value* Show face analysis ([item ▾]) in the 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. Face dictionary Get the list of names in the face dictionary. *returns a value* Train image ([item ▾]) face ([item ▾]) to name ([pibo]) Train face from image. Delete face name ([pibo]) from face training data Delete a specific face from training faces. Recognize who is image ([item ▾]) face ([item ▾]) Recognize who faces are in an image. *returns a value* Save face training data to file [Select folder ▾] ([facedb]) Save face training data to file. Load face training data from file [Select folder ▾] ([facedb]) Load face training data from file. Analyze face direction/distance in the image ([item ▾]) Analyze face direction/distance in the image. *returns a value* Show face direction/distance ([item ▾]) in the image ([item ▾]) Show face direction/distance in the image Load Object detection model [Select folder ▾] ([yolo11s]) .onnx Load Object detection model Find objects in the image ([item ▾]) Find objects in the image. *returns a value* Find objects in the image ([item ▾]) (Raw) 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 ▾]) (RAW) 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. Analyze pose results in ([item ▾]) and save to [motion ▾] Evaluate and interpret pose data from the image and save the results. *returns a value* Setting tracker at coordinates ([0]) ([0]) , ([0]) ([0]) of image ([item ▾]) Set a tracker for a specific location in the image. Track thing in the image ([item ▾]) Track thing in the image. *returns a value* Show tracking result ([item ▾]) in the image ([item ▾]) Show tracking result in the image. Load Hand gesture model [gesture_recognizer ▾] Load Hand gesture model. Load Hand gesture model [Select folder ▾] ([gesture_recognizer]) .task Load Hand gesture model Recognize 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. Detect Marker length ([5]) 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 classifier 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 ([item ▾]) with classifier model Classify the image with the loaded classifier 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* Draw what the classifier saw on image ([item ▾]) Draws what the last [Classify with classifier model] saw on that image: points and bones for hand and pose, points for face, plus the class name and probability. ### Utils Delay for ([1]) seconds Pause the process for a specified duration of seconds. Get time value 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 ([item ▾]) Retrieve the value associated with a specific key in a dictionary. *returns a value* Append { ([Key name]) : ( ) } to dictionary ([item ▾]) Add a new key-value pair to an existing dictionary. Create empty dictionary Generate a new empty dictionary. *returns a value* set array ([item ▾]) [ ([0]) : ([0]) , ([0]) : ([0]) ] to ([item ▾]) Set the values of the specified range in the array. Check if [File ▾] ([Path]) exists Confirm the existence of a file or directory. *returns a value* Convert ([1]) to String type Change a variable's type to String. *returns a value* Convert ([1]) to [Integer ▾] type 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*