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
ifcondition block to your workspace to handle logic when the button is pressed. - From the logic section, drag a
NOToperator block and place it inside theifcondition block. - Drag the
READfunction block and place it inside theNOTblock. - From the dropdown in the
READblock:- Select button as the sensor type.
- Select the pin connected to your button (e.g.,
P0).
- Inside the
ifblock:- Drag a block to turn on the blue LED.
- Then drag a
ScreenDisplayblock and use it to print the word "Pressed" on the screen.
- Explanation:
- The button outputs
1when not pressed and0when pressed. - The
NOToperator inverts the signal so that theifcondition 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
