2.5 Button Module
A button module is a digital input device that detects when it is pressed. It is commonly used to start or stop processes in a project.
Example Applications:
- Robot mode selector
- Manual control triggers
- Game controllers
2.5.1 Example Code for the Button
This particular button typically outputs HIGH (1) when not pressed and LOW (0) when pressed. To detect a button press, we can use a NOT logic block to reverse the signal.
- Start by connecting the button module to one of the available single-pin ports using the provided Type-C cable.
- Choose the corresponding pin on the controller to which the button is connected, for example,
P0
,P1
, orP2
. - Drag an
if
condition block to your workspace to handle logic when the button is pressed. - From the logic section, drag a
NOT
operator block and place it inside theif
condition block. - Drag the
READ
function block and place it inside theNOT
block. - From the dropdown in the
READ
block:- Select button as the sensor type.
- Select the pin connected to your button (e.g.,
P0
).
- Inside the
if
block:- Drag a block to turn on the blue LED.
- Then drag a
ScreenDisplay
block and use it to print the word "Pressed" on the screen.
- Explanation:
- The button outputs
1
when not pressed and0
when pressed. - The
NOT
operator inverts the signal so that theif
condition is true when the button is actually pressed.
- The button outputs

Figure 2.5.1a: Button press detection and LED activation using block-based logic with NOT operator