PicoBricks Library is used to drive the modules on the Robotistan PicoBricks Board.
For details of the board and how to set it up, please refer to PicoBricks Board section.
In the block descriptions below, we have used a template image of the board with the relevant component colored in orange, to designate the location of the component. This way one can easily verify the component that the block is controlling.
In the template picture above, the DHT sensor location is colored in orange, pointing to the blue DHT sensor on the board (second from the bottom left).
For each block, there is a short description entry and a detailed block and component description. You can click on block pictures in the short description table to access the details and sample codes.
Sample codes on how to use the blocks have been provided. To try them out, all you have to do is open a browser session of the MicroBlocks IDE and drag and drop them onto the editor programming area. Then you can just click on them and see the results.
To test any of the sample codes below, just drag and drop them onto the MicroBlocks IDE.
The library consists of a set of simple services, that together allow the user to have complete control of the PicoBricks Board and the modules on it.
PicoBricks Library has two distinct types of block shapes:
oval: these are reporter blocks that return some kind of information back. The user would normally either assign these to a project variable or use it in a suitable input slot of other blocks. The return information type can be any of the supported data types.
rectangular: these are command blocks that perform a programmed function and do not return any information.
This block makes a short buzz sound via the speaker. The duration of the sound can be set in milliseconds. For a more detailed ability to control the tone functionality, please refer to the TONE Library details.
This block returns the status of the button next to the red LED.
When the button is pressed, it will return a true value; when not pressed, it will return a false value.
An RGB LED is a combination of 3 LEDs in just one package:
1x Red LED
1x Green LED
1x Blue LED
You can produce almost any color by combining those three colors.
RGB LED colors are set using the color picker in the set color block. However, this is not a convenient method for programmatic setting of colors.
This block will return a color code according to the R, G, B values selected. This block can be placed into the color area of the set color block.
The on-board DHT11 sensor provides the ability to read the Humidity and the Temperature of the board environment. The sensor can measure temperature from 0°C to 50°C and humidity from 20% to 90% with an accuracy of ±1°C and ±1%.
An LDR is a component that has a (variable) resistance that changes with the light intensity that falls upon it. This allows them to be used in light sensing circuits. Light Dependent Resistors (LDR) are also called photoresistors.
The values returned by this sensor are percentages proportional to the light detected. When there is almost no light, the values will be towards the low end (0). And when there is any light, depending on the type and intensity, the readings will be towards the high end (100).
A potentiometer is an ordinary variable resistor. It functions as a potential divider, which is used to generate a voltage signal depending on the location of the potentiometer. This is the signal that can be used for a very wide variety of applications including an amplifier gain control, measurement of the distance or angles, tuning of the circuits and many more.
Potentiometers are wired as variable voltage dividers: connect +V to one side, connect the other side to ground, and the middle pin will output a voltage between 0 and +V.
In our case, the the block will return values from 0 to 1023, representing the voltage range of 0 - 3.3V.
Generates a random color value that can be used in any of the RGB color inputs.
This is a standard single LED component of red color.
The block will allow the selection of TRUE=on or FALSE=off and set the LED accordingly.
This is a relay switch, that enables one to turn the AC side switch ON or OFF by setting this block to the corresponding setting.
When set to TRUE=on (or FALSE=off) the green connectors on the component will be internally connected (or disconnected). This can be used to turn on / off any device that is connected to the green connectors.
Controls the DC motors connected to the Motor control module.
Please make sure to switch the jumpers to the "DCMotor" position and connect the motors to the green power connectors.
See blue markings in the image below.
Allows one to select a color from the color picker and set the RGB LED to that color. You can also use the PicoBricks_RGB random color or the PicoBricks_RGB color to generate colors.
The on-board DHT11 sensor provides the ability to read the Humidity and the Temperature of the board environment. The sensor can measure temperature from 0°C to 50°C and humidity from 20% to 90% with an accuracy of ±1°C and ±1%.
Turns off the RGB LED light.
PicoBricks Board components are pre-assembled and wired via the printed ciruit board they are mounted on. Therefore their connections to the pico processor is predetermined by the manufacturer of the board. As long as you do not break off the components and reassemble them to your liking, the pins assignments to drive them is as specified in this block.
This block will record the pin assignments for all other blocks to use.
If you break off / seperate the components and rewire them to other pin locations, you can change the assignments in this block and continue using the library.
Used to rescale sensor values to desired value ranges.
In the sample program below, LDR values in the range of 0-1023 are rescaled to 0-100 to be shown as percentages.
PicoBricks board contains ten components premounted. The Library, however, only has blocks for seven of them; the OLED screen, Motor Control, and Wireless Comm components are not directly covered by the library.
In this section, we will describe how one can make use of these components, as well as some special information about them.
OLED display module is programmed by using the MicroBlocks graphics library called OLED Graphics. It is located under Libraries+ / Graphics / OLED Graphics.ubl in the IDE.
For details of the library blocks and operations, refer to OLED Library.
For a project that describes advanced use of the library and data transfer, please refer to SNAP to MicroBlocks.
This module is used to control SERVO motors and DC motors.
SERVO motor programming is supported via the MicroBlocks library Servo. It is located under Libraries+ / Servo.ubl in the IDE.
DC Motor support is provided in the library directly. However, there is a caveat: since the motor connections are only via thee-wire cable, it is not possible to programmatically reverse the direction of the DC motors. The only way to change the direction of the DC motors is to change the way the wires are connected.
For a detailed project that uses the DC and Servo motors, please refer to PicoBricks Servo and DC Motor Control.
This module enables PicoBricks to communicate with other environments using either a WIFI module or a Bluetooth module and is connected to the Serial IO ports of the Pico.
The specific WIFI module supported is the ESP01 (ESP8266). This is very small form-factor unit that is programmed using the AT command set.
Likewise, the Bluetooth modules supported can be any one that is programmed via the AT command set. Most popular ones are the HC-05 or HC-06 units.
Both communications options are programmed using the AT command sets of the specific boards. Since the AT programming is done over the Serial comm port of the processor, the command blocks to do that are already present in the MicroBlocks.
![]() |
![]() |
---|
Simply enable the show advanced blocks option under the Settings in the menu. This will display the Comm blocks category. Within you will find the Serial set of blocks.