Blocks and Python
Build a program, understand conversion limits, and use timer and input events.
Build with blocks
Open Blocks and choose Actions, Sensors, Events, Logic, or Math & text. Drag a block into a matching connection. Numeric values, text, and conditions have different input types; use compatible blocks and respect field limits.
Place your main sequence under Start. Use conditions to choose an action, loops to repeat it, and Wait (shown as DELAY on the English block) to delay later commands. A block sitting loose on the canvas is not automatically part of the Start sequence.
To remove a block, drag it to the trash. To undo or redo an edit, use the Undo and Redo buttons at the upper right of the block area, Edit → Undo, or Ctrl+Z / Ctrl+Y. A change you make in Python and bring back to Blocks counts as one undo step, so earlier and later block edits stay undoable. Opening a lesson, New, and recovery start a fresh history. For canvas movement and zoom, see The workspace.
Selecting a category shows a short tip below the block list. If Python is selected, the Build with blocks card offers Switch to Blocks and keeps your code. If converting to editable blocks could change the original text, Edit this code in Python offers Open Python. Closing a tip keeps the program unchanged.
Switch to Python
Choose Python to read or edit the supported PAVA program. The two editors share PAVA's supported Python subset; the app is not an unrestricted Python interpreter.
Unsupported or incomplete Python remains as written, including comments and indentation. If the app cannot convert it to blocks, continue editing in Python rather than expecting an approximate replacement program. Saving your text and running it are separate actions.
The protected Blocks view also shows Edit this code in Python with Open Python so you can return to the original text. When the program cannot provide a circuit preview, the diagram area shows No connection diagram. Your code stays unchanged; open Python and check the supported commands and syntax before trying to run it.
Hover over a recognized command for an explanation. Comments and strings do not trigger command help. Hover help does not change or execute code. Ctrl+/ toggles Python comments.
Wait block values are milliseconds; time.sleep() values are seconds. For example, a Wait value of 1000 corresponds to one second. Check the command help before changing units.
Adjust Python text size
Use +, Reset Python font size, and − at the editor's lower right. The default 100% is 20 px; the range is 70–160% (14–32 px), in 2 px steps. The choice stays with this editor session. It changes text size, not the saved code. Interface text size is a separate Appearance setting.
Use the supported program limits
Use a constant from 0 to 3600 seconds for time.sleep(). Repeat counts must be whole numbers no greater than 10,000. Keep a board program within 100 KB and 1,000 lines; excessive nesting or complex expressions can also be rejected. Read the validation message before trying to run or compile again.
Use several LEDs
The LED block has a pin, a color, and On or off. The default, pin 13 and Red, is the red LED on D13, so earlier lessons and programs keep working. To use another LED, change the pin and choose Red, Yellow, or Green. In Python, the same command is led.set(7, "GREEN", "ON"); led.set("ON") still means the red LED on D13.
Use one color for each pin. Board code accepts LED pins D2–D13. Connect an external LED through a current-limiting resistor.
Add events
Place event blocks beside one Start block. The supported event types are:
| Event | When it runs |
|---|---|
| Timer | Repeats at its interval, from 1 to 3,600,000 milliseconds |
| Switch | Runs once when a switch on D2–D12 is pressed; holding does not repeat it |
| External input | Runs once on a LOW → HIGH transition on D2–D12 |
Use the virtual LOW/HIGH control to experiment with external input. On a physical Uno, switch events use a switch to GND with INPUT_PULLUP and 20 ms debouncing. External-input events use INPUT and need a defined digital signal and common ground.
An input pin cannot also be an output. An external input cannot share a pull-up switch pin. Use at most 16 event blocks and do not duplicate a timer interval or input trigger.
Understand event timing
Events keep listening after Start finishes. Handlers execute one at a time and can interrupt a Wait in Start. A Wait inside a handler completes before another handler begins. Repeated pending triggers combine into one callback, and missed timer ticks are skipped. Keep each handler short.
Pause freezes virtual time. Stop, Reset, virtual power-off, or editing clears the old run. On a physical Uno, short pulses between polling steps can be missed. Some kit-only blocks remain unsupported; a block or catalog picture is not a promise of simulation or board support.
Try Simulation, then Controller board when you are ready to inspect generated code.

