Skip to content

Updated heading and markdown formatting for Modulino #2517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ software:
- ide-v2
- web-editor
---

The Modulino Buttons is a modular sensor that provides tactile input and visual feedback, making it perfect to add interactive controls to your projects!

The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple modulinos in a very simple way. In addition to the QWIIC's connectors, the Modulinos also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible.

![Module demonstration](assets/connection-guide-buttons.gif)

Pressing a button pulls the signal LOW, and each button has an onboard pull-up resistor. The LEDs can be controlled independently through the onboard microcontroller.


# General Characteristics
## General Characteristics

The **Modulino Buttons** module uses three tactile buttons and LEDs, which do not have native I²C capabilities. Instead, the buttons and LEDs are controlled by the Modulino's onboard microcontroller (STM32C011F4U6TR). This microcontroller provides I²C communication, allowing for flexible reading of button states and control of the LEDs. One unique feature of this setup is the ability to change the I²C address via software. This means the address can be modified based on your application needs, making it adaptable to different system configurations.

Expand All @@ -40,6 +42,7 @@ The default I²C address for the **Modulino Buttons** module is:
| 0x7C | 0x3E | Any custom address (via software configuration) |

When scanning for I²C address on the bus, you might find the modulino using the **Hardware I²C Address**. However, you should always use the **Modulino I²C Address** when using the official Modulino library.

Later in this article we teach how to [change the address](#how-to-change-i2c-address).

## Pinout
Expand Down Expand Up @@ -105,58 +108,77 @@ The Modulino Buttons uses a simple circuit, as shown in the schematic below:
![Full Schematic Modulino Buttons](assets/schematic.png)

The main components are the **three tactile buttons**, **three user-programmable LEDs** and the **STM32C011F4U6TR** microcontroller (U1), which handles button state reading, LED control, as well as I²C communication.

You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4.

There's also a small power LED indicator that lights up when the board is on.
You can grab the full schematic and PCB files from the [Modulino Buttons](https://docs.arduino.cc/hardware/modulinos/modulino-buttons) product page.

## How To Connect Your Modulino

The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It’s plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go.

Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model.

![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-buttons.png)

## QWIIC Connector
### QWIIC Connector

Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections.

QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors:

- GND
- 3.3V
- SDA (Data)
- SCL (Clock)

![Connection Guide QWIIC](assets/connection-guide-buttons-qwiik.png)

The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them.

## Solderable Header
### Solderable Header

When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board.

![Connection Guide Solder Pads](assets/connection-guide-buttons-jumper.png)

## Daisy-Chaining Multiple Modulinos
### Daisy-Chaining Multiple Modulinos

Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules.
Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus.

This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity.

![Modulino Wiring Options](assets/connection-guide-buttons-qwiic-chain.png)

***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup’s performance. Ensure your cables are properly connected and capable of handling the required data transfer.
Each module should have a unique address on a chain if you plan to address them individually. Later in this article we teach how to [change the address](#how-to-change-i2c-address). Multiple modules with the same address will cause conflicts on the I²C bus and will not allow you to address them individually.***

# How To Use Your Modulino
## Installing The Modulino Library
## How To Use Your Modulino

### Installing The Modulino Library

You need the official Modulino library available [here](https://docs.arduino.cc/libraries/modulino/) to use the Modulino Buttons.

With the Arduino IDE you get some tools that make adding a library easier. To learn how to install the IDE please visit our [page](https://docs.arduino.cc/software/ide-v2/tutorials/getting-started/ide-v2-downloading-and-installing/).

After opening the IDE, a tab should be visible on the left. Press the book icon for "library" as highlighted in the image.

![IDE Library Tab](assets/IDE-Left-Tab.png)

The process should look like this:

![Library Install](assets/library-install.gif)

A message will appear after the installation is successful.

# Getting Button Press Data
### Getting Button Press Data

Interacting with the Modulino Buttons module is simple using the `Modulino` library.

For the **Buttons** module, there are two key functions:

- `update()`**:** Requests new data from the button module.
- `isPressed(index)`**:** Checks if a specific button (`A`, `B`, or `C`) is pressed.
- `setLeds(A, B, C)`**:** Sets the state of the LED (`A`, `B`, or `C`).
Expand Down Expand Up @@ -195,11 +217,12 @@ void loop() {
```
The code example provided shows how to initialize the button module, read button states, and control the LEDs. The program begins by turning on all three LEDs, then continuously checks for button presses and reports them through the serial monitor. Each button is identified by its index (0 for A, 1 for B, 2 for C), making it easy to expand the functionality for more complex interactions. This simple interface can be adapted to trigger various actions in your projects, from controlling other components to navigating menus or implementing game controls.

# Detecting Button Events
### Detecting Button Events

The Modulino Buttons module can be enhanced with the [Button2 library](https://docs.arduino.cc/libraries/button2/) to detect various button events beyond simple presses. This approach allows you to respond to single clicks, double clicks, triple clicks, and long presses.

For the **Button Events** functionality, there are several key functions:

- `setButtonStateFunction(function)`**:** Sets a custom function that provides the button state.
- `setClickHandler(function)`**:** Sets a handler for single-click events.
- `setDoubleClickHandler(function)`**:** Sets a handler for double-click events.
Expand Down Expand Up @@ -264,16 +287,19 @@ void loop() {

The code example provided shows how to integrate the Button2 library with the Modulino Buttons module to detect advanced button interactions. It creates a virtual button connected to Button A (index 0) and sets up handlers for different types of clicks. The `button0StateHandler()` function serves as a bridge between the Modulino hardware and the Button2 library by converting the button state to the expected format. When running, the program will detect and report single clicks, double clicks, triple clicks, and long presses through the serial monitor. This approach enables more sophisticated user interfaces in your projects, from navigating multi-level menus to implementing different functions based on how a user interacts with a single button.

## How To Change I2C Address
### How To Change I2C Address

An example sketch, AddressChanger, is also included with the library inside the `Utilities` folder and available [here](https://github.com/arduino-libraries/Modulino/blob/main/examples/Utilities/AddressChanger/AddressChanger.ino). This sketch changes the I²C address at a software level on the Module's microcontroller.

![Example location on the IDE](assets/AdressChangeIDE.png)

- Connect the module to your board, remove any other modules that might be in the chain. Connection must be via I²C.
- Upload the sketch.
- Open the Serial Monitor.
- Text should now appear. Make sure the correct bauld-rate is selected if the displayed characters seem corrupted.

![Expected console output](assets/adressChanger.png)

- Select the address and confirm. Valid I²C addresses range from 0x08 to 0x77 (7-bit values in hexadecimal format, e.g., 0x42).
- Your address should now have changed. Make sure to take note of the selected address.

Expand All @@ -285,30 +311,37 @@ ModulinoButtons buttons(0x3E); // Replace 0x3E with your specific address
```


# Troubleshooting
## Troubleshooting

### Buttons Not Responding

## Buttons Not Responding
If your Modulino's power LED isn't on or the buttons aren't responsive, first check that the board is properly connected:

- Ensure both the board and the Modulino are connected to your computer, and that the power LEDs on both are lit.
- If the issue persists, make sure the Qwiic cable is properly clicked into place.

## Library Not Installed Properly
### Library Not Installed Properly

If you encounter an issue with the `#include "modulino.h"` command, verify that the Modulino library is correctly installed:

- Check your IDE to ensure the library is installed and up-to-date.
- Re-install the library through the Library Manager.

## LEDs Not Working
### LEDs Not Working

If the LEDs aren't lighting up as expected, make sure:

- The correct LED states are being set in your code (true for on, false for off).
- All exposed electronics are not touching any conductive surfaces, as this could interfere with the operation.

# Conclusion
## Conclusion

The **Modulino Buttons** is a digital input and output device that communicates over I²C and follows the Modulino form factor. It includes standard Qwiic connectors for quick, solderless connections and easy daisy-chaining with other modules. Paired with the Modulino library, it makes detecting button presses and controlling LEDs straightforward, allowing you to focus on experimenting or building your system logic. It's a small, reliable module suited for both user interfaces and interactive control systems.

# What Is Next?
## What Is Next?

Now that you've learned how to use your Modulino Buttons, you're all set to integrate it into your projects!

- Create a simple menu system where each button performs a different function.
- Build a game controller for a simple arcade-style game.
- Use the buttons to control other Modulino devices in your project.
Expand Down
Loading