-
-
Notifications
You must be signed in to change notification settings - Fork 498
[PXCT-1111] Modulino - Revamp tutorials - all nodes #2623
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
Open
pedromsousalima
wants to merge
18
commits into
main
Choose a base branch
from
pedromsousalima/modulinos/revamp-get-started
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fb79a1a
Initial
pedromsousalima a612028
Changed product page and visuals
pedromsousalima d4f5cd6
Linter shenaniganz
pedromsousalima 03e2b64
Spell-Checker
pedromsousalima de32c12
Linter
pedromsousalima a9c450d
Update content/hardware/11.accessories/modulino-nodes/modulino-buzzer…
pedromsousalima f66c832
Apply suggestion from @jhansson-ard
pedromsousalima 4e70d77
Apply suggestion from @jhansson-ard
pedromsousalima e70bcb8
Apply suggestion from @jhansson-ard
pedromsousalima 7de52ad
Apply suggestion from @jhansson-ard
pedromsousalima 00c8d11
Apply suggestion from @jhansson-ard
pedromsousalima be13074
Apply suggestion from @jhansson-ard
pedromsousalima 5f926a8
applleid feedback
pedromsousalima 23916a0
Merge branch 'pedromsousalima/modulinos/revamp-get-started' of https:…
pedromsousalima 12e7a79
symulink´s
pedromsousalima 2796cdc
Revert "symulink´s"
pedromsousalima 45db835
Add symlinks
jacobhylen 17fabf6
Applied simulinks to tutorials
pedromsousalima File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-157 KB
...no-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/AdressChangeIDE.png
Binary file not shown.
Binary file removed
BIN
-64.1 KB
...ulino-buttons/tutorials/how-buttons-ardu/assets/Modulino_Buttons_Power_Tree.png
Binary file not shown.
Binary file removed
BIN
-33.9 KB
...lino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/adressChanger.png
Binary file not shown.
Binary file removed
BIN
-91.8 KB
...o-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons-jumper.png
Binary file not shown.
Binary file removed
BIN
-84.7 KB
...tons/tutorials/how-buttons-ardu/assets/connection-guide-buttons-qwiic-chain.png
Binary file not shown.
Binary file removed
BIN
-132 KB
...no-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons-qwiik.png
Binary file not shown.
Binary file removed
BIN
-101 KB
...modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons.png
Binary file not shown.
349 changes: 0 additions & 349 deletions
349
...dulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/how-to-buttons-ardu.md
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-59.8 KB
...ulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/ButtonsPinouts.png
Binary file not shown.
Binary file removed
BIN
-64.1 KB
...odulino-buttons/tutorials/how-buttons-mp/assets/Modulino_Buttons_Power_Tree.png
Binary file not shown.
Binary file removed
BIN
-91.8 KB
...ino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons-jumper.png
Binary file not shown.
Binary file removed
BIN
-84.7 KB
...uttons/tutorials/how-buttons-mp/assets/connection-guide-buttons-qwiic-chain.png
Binary file not shown.
Binary file removed
BIN
-132 KB
...lino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons-qwiik.png
Binary file not shown.
Binary file removed
BIN
-244 KB
...s/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons.gif
Binary file not shown.
Binary file removed
BIN
-101 KB
...s/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons.png
Binary file not shown.
Binary file removed
BIN
-15.9 KB
...no-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/mp-usb-connection.png
Binary file not shown.
Binary file removed
BIN
-202 KB
...s/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/schematic.png
Binary file not shown.
299 changes: 0 additions & 299 deletions
299
...s/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/how-to-buttons-mp.md
This file was deleted.
Oops, something went wrong.
File renamed without changes
File renamed without changes
File renamed without changes
352 changes: 352 additions & 0 deletions
352
...11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons/content.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,352 @@ | ||
| --- | ||
| title: "Getting Started with Modulino Buttons" | ||
| description: "Complete guide for the Modulino Buttons and programming with Arduino and MicroPython." | ||
| tags: | ||
| - Modulino | ||
| - Buttons | ||
| - Input | ||
| - LED | ||
| - QWIIC | ||
| - I2C | ||
| author: 'Pedro Sousa Lima' | ||
| hardware: | ||
| - hardware/11.modulinos/modulinos/modulino-buttons | ||
| software: | ||
| - ide-v2 | ||
| - web-editor | ||
| - micropython | ||
| --- | ||
|
|
||
|  | ||
|
|
||
| The Modulino Buttons is a modular sensor that provides tactile input and visual feedback, making it perfect to add interactive controls to your projects! 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. | ||
|
|
||
| ## Hardware Overview | ||
|
|
||
| ### General Characteristics | ||
|
|
||
| The **Modulino Buttons** module uses three tactile buttons and LEDs, 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. | ||
|
|
||
| | Specification | Details | | ||
| |-------------------|-----------------------------| | ||
| | Buttons | 3 × Tactile pushbuttons | | ||
| | LEDs | 3 × Indicator LEDs (orange) | | ||
| | Power Supply | 3.3 V | | ||
| | Interface | UART, SWD, I2C | | ||
| | Pull-up Resistors | Integrated on button inputs | | ||
|
|
||
| One unique feature of this setup is the ability to change the I²C address via software, making it adaptable to different system configurations. | ||
|
|
||
| The default I²C address for the **Modulino Buttons** module is: | ||
|
|
||
| | Modulino I²C Address | Hardware I²C Address | Editable Addresses (HEX) | | ||
| |----------------------|----------------------|-------------------------------------------------| | ||
| | 0x7C | 0x3E | Any custom address (via software configuration) | | ||
|
|
||
| ### Pinout | ||
|
|
||
|  | ||
|
|
||
| #### 1x10 Header | ||
|
|
||
| | Pin | Function | | ||
| |-------|----------------| | ||
| | A | Button A | | ||
| | GND | Ground | | ||
| | 3V3 | 3.3 V Power | | ||
| | PF2 | RESET | | ||
| | SWCLK | SWD Clock | | ||
| | SWDIO | SWD Data | | ||
| | TX1 | USART Transmit | | ||
| | RX1 | USART Receive | | ||
| | B | Button B | | ||
| | C | Button C | | ||
|
|
||
| #### 1x4 Header (I2C) | ||
|
|
||
| | Pin | Function | | ||
| |-------|--------------| | ||
| | GND | Ground | | ||
| | 3.3 V | Power Supply | | ||
| | SDA | I²C Data | | ||
| | SCL | I²C Clock | | ||
|
|
||
| ### Power Specifications | ||
|
|
||
| | Parameter | Condition | Minimum | Typical | Maximum | Unit | | ||
| |------------------|------------------------------|---------|-------------|---------|------| | ||
| | Supply Voltage | - | - | 3.3 (QWIIC) | - | V | | ||
| | LED Current Draw | Single LED Active (A,B or C) | - | 2.5 | - | mA | | ||
|
|
||
| The module includes a power LED that draws 1 mA and turns on as soon as it is powered. | ||
|
|
||
| ### Schematic | ||
|
|
||
| The Modulino Buttons uses a straightforward circuit design featuring three tactile buttons, three user-programmable LEDs, and the STM32C011F4U6TR microcontroller. | ||
|
|
||
|  | ||
|
|
||
| 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. | ||
|
|
||
| You can grab the full schematic and PCB files from the [Modulino Buttons page](https://docs.arduino.cc/hardware/modulinos/modulino-buttons). | ||
|
|
||
| ## Programming with Arduino | ||
|
|
||
| The Modulino Buttons is fully compatible with the Arduino IDE and the official Modulino library. The following examples showcase basic button reading and LED control functionality that can be easily integrated into your interactive projects. | ||
pedromsousalima marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Install the Modulino library via the Arduino IDE Library Manager | ||
| - Connect your Modulino Buttons via QWIIC or solderable headers | ||
|
|
||
| For detailed instructions on setting up your Arduino environment and installing libraries, please refer to the [Getting Started with Modulinos guide](./how-general). | ||
|
|
||
| Library repository available [here](https://github.com/arduino-libraries/Arduino_Modulino). | ||
|
|
||
| ### Basic Example | ||
|
|
||
| ```arduino | ||
| #include <Modulino.h> | ||
|
|
||
| // Create object instance | ||
| ModulinoButtons buttons; | ||
|
|
||
| void setup() { | ||
| Serial.begin(9600); | ||
| Modulino.begin(); | ||
| buttons.begin(); | ||
|
|
||
| // Function to control the LEDs on top of each button | ||
| buttons.setLeds(true, true, true); | ||
| } | ||
|
|
||
| void loop() { | ||
| // Request new data from the Modulino Buttons | ||
| if (buttons.update()) { | ||
| // Check if any button has been pressed | ||
| if (buttons.isPressed(0)) { | ||
| Serial.println("Button A pressed!"); | ||
| } else if (buttons.isPressed(1)) { | ||
| Serial.println("Button B pressed!"); | ||
| } else if (buttons.isPressed(2)) { | ||
| Serial.println("Button C pressed!"); | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Key Functions | ||
|
|
||
| - `update()`: Requests new data from the button module | ||
| - `isPressed(index)`: Checks if a specific button (0=A, 1=B, 2=C) is pressed | ||
| - `setLeds(A, B, C)`: Sets the state of the LEDs (true=on, false=off) | ||
|
|
||
| ### Advanced Example - Button Events with Button2 Library | ||
|
|
||
| The Modulino Buttons can be enhanced with the Button2 library to detect various button events beyond simple presses. | ||
|
|
||
| ```arduino | ||
| #include "Modulino.h" | ||
| #include "Button2.h" | ||
|
|
||
| Button2 button; | ||
| ModulinoButtons modulino_buttons; | ||
|
|
||
| uint8_t button0StateHandler() { | ||
| modulino_buttons.update(); | ||
| return modulino_buttons.isPressed(0) ? LOW : HIGH; // fake a normal button -> LOW = pressed | ||
| } | ||
|
|
||
| void handler(Button2& btn) { | ||
| switch (btn.getType()) { | ||
| case single_click: | ||
| break; | ||
| case double_click: | ||
| Serial.print("double "); | ||
| break; | ||
| case triple_click: | ||
| Serial.print("triple "); | ||
| break; | ||
| case long_click: | ||
| Serial.print("long"); | ||
| break; | ||
| } | ||
| Serial.print("click"); | ||
| Serial.print(" ("); | ||
| Serial.print(btn.getNumberOfClicks()); | ||
| Serial.println(")"); | ||
| } | ||
|
|
||
| void setup() { | ||
| Serial.begin(115200); | ||
| Modulino.begin(); | ||
| modulino_buttons.begin(); | ||
|
|
||
| button.setDebounceTime(35); | ||
| button.setButtonStateFunction(button0StateHandler); | ||
| button.setClickHandler(handler); | ||
| button.setDoubleClickHandler(handler); | ||
| button.setTripleClickHandler(handler); | ||
| button.setLongClickHandler(handler); | ||
| button.begin(BTN_VIRTUAL_PIN); | ||
| } | ||
|
|
||
| void loop() { | ||
| button.loop(); | ||
| } | ||
| ``` | ||
|
|
||
| ## Programming with MicroPython | ||
|
|
||
| The Modulino Buttons is fully compatible with MicroPython through the official Modulino MicroPython library. The following examples demonstrate how to detect button presses, handle various button events, and control the integrated LEDs in your MicroPython projects. | ||
pedromsousalima marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Install the Modulino MicroPython library | ||
| - Ensure Arduino Lab for MicroPython is installed | ||
|
|
||
| For detailed instructions on setting up your MicroPython environment and installing packages, please refer to the [Getting Started with Modulinos guide](./how-general). | ||
|
|
||
| ### Basic Example | ||
|
|
||
| ```python | ||
| from modulino import ModulinoButtons | ||
| from time import sleep | ||
|
|
||
| buttons = ModulinoButtons() | ||
|
|
||
| # Define button press actions | ||
| buttons.on_button_a_press = lambda : print("Button A pressed") | ||
| buttons.on_button_a_long_press = lambda : print("Button A long press") | ||
| buttons.on_button_a_release = lambda : print("Button A released") | ||
|
|
||
| buttons.on_button_b_press = lambda : print("Button B pressed") | ||
| buttons.on_button_b_long_press = lambda : print("Button B long press") | ||
| buttons.on_button_b_release = lambda : print("Button B released") | ||
|
|
||
| buttons.on_button_c_press = lambda : print("Button C pressed") | ||
| buttons.on_button_c_long_press = lambda : print("Button C long press") | ||
| buttons.on_button_c_release = lambda : print("Button C released") | ||
|
|
||
| # LED Sequence: Turn each LED on with a delay, then turn them off | ||
| buttons.led_a.on() | ||
| sleep(0.5) | ||
| buttons.led_b.on() | ||
| sleep(0.5) | ||
| buttons.led_c.on() | ||
| sleep(0.5) | ||
| buttons.set_led_status(False, False, False) # Turn off all LEDs | ||
|
|
||
| while True: | ||
| buttons_state_changed = buttons.update() | ||
|
|
||
| if buttons_state_changed: | ||
| led_a_status = buttons.is_pressed(0) # Turn LED A on if button A is pressed | ||
| led_b_status = buttons.is_pressed(1) # Turn LED B on if button B is pressed | ||
| led_c_status = buttons.is_pressed(2) # Turn LED C on if button C is pressed | ||
| buttons.set_led_status(led_a_status, led_b_status, led_c_status) | ||
| ``` | ||
|
|
||
| ### Key Functions and Properties | ||
|
|
||
| - `.on_button_x_press`: Callback for button press events | ||
| - `.on_button_x_long_press`: Callback for long press events | ||
| - `.on_button_x_release`: Callback for button release events | ||
| - `.led_x.on()/.off()`: Control individual LEDs | ||
| - `.set_led_status(a, b, c)`: Set all LED states at once | ||
| - `.is_pressed(index)`: Check if a button is currently pressed | ||
| - `.update()`: Check for button state changes | ||
|
|
||
| ### Advanced Example - Menu System | ||
|
|
||
| ```python | ||
| from modulino import ModulinoButtons | ||
| from time import sleep | ||
|
|
||
| buttons = ModulinoButtons() | ||
|
|
||
| # Menu system variables | ||
| menu_items = ["Option 1", "Option 2", "Option 3", "Settings", "Exit"] | ||
| current_index = 0 | ||
| in_submenu = False | ||
|
|
||
| def show_menu(): | ||
| """Display current menu state via LEDs and serial""" | ||
| print("\n--- MENU ---") | ||
| for i, item in enumerate(menu_items): | ||
| prefix = ">" if i == current_index else " " | ||
| print(f"{prefix} {item}") | ||
|
|
||
| # Show position with LEDs | ||
| buttons.set_led_status( | ||
| current_index == 0, | ||
| current_index == 2, | ||
| current_index == 4 | ||
| ) | ||
|
|
||
| def next_item(): | ||
| """Move to next menu item""" | ||
| global current_index | ||
| current_index = (current_index + 1) % len(menu_items) | ||
| show_menu() | ||
|
|
||
| def previous_item(): | ||
| """Move to previous menu item""" | ||
| global current_index | ||
| current_index = (current_index - 1) % len(menu_items) | ||
| show_menu() | ||
|
|
||
| def select_item(): | ||
| """Select current menu item""" | ||
| print(f"\n✓ Selected: {menu_items[current_index]}") | ||
|
|
||
| # Flash all LEDs to confirm selection | ||
| for _ in range(3): | ||
| buttons.set_led_status(True, True, True) | ||
| sleep(0.1) | ||
| buttons.set_led_status(False, False, False) | ||
| sleep(0.1) | ||
|
|
||
| # Configure button actions | ||
| buttons.on_button_a_press = previous_item # Navigate up | ||
| buttons.on_button_b_press = select_item # Select | ||
| buttons.on_button_c_press = next_item # Navigate down | ||
|
|
||
| # Initialize | ||
| print("Menu Navigation System") | ||
| print("A: Previous | B: Select | C: Next") | ||
| show_menu() | ||
|
|
||
| # Main loop | ||
| while True: | ||
| buttons.update() | ||
| sleep(0.01) | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Buttons Not Responding | ||
|
|
||
| If your Modulino's power LED isn't on or the buttons aren't responsive: | ||
| - Ensure both the board and the Modulino are connected properly | ||
| - Verify that the power LEDs on both are lit | ||
| - Check that the QWIIC cable is properly clicked into place | ||
|
|
||
| ### LEDs Not Working | ||
|
|
||
| If the LEDs aren't lighting up as expected: | ||
| - Verify correct LED states are being set in your code | ||
| - Check that exposed electronics are not touching conductive surfaces | ||
| - Ensure adequate power supply for LED operation | ||
|
|
||
| ## Project Ideas | ||
|
|
||
| - **Simple Menu System**: Each button performs a different function or navigates menus | ||
| - **Game Controller**: Build controls for arcade-style games | ||
| - **Interactive Control Panel**: Control other Modulino devices in your project | ||
| - **Pattern Memory Game**: Create a Simon-style memory game with LED feedback | ||
| - **Morse Code Trainer**: Practice Morse code with button input and LED feedback | ||
| - **Smart Home Controller**: Three-button interface for home automation | ||
| - **Music Box Controller**: Each button plays different notes or controls playback | ||
1 change: 1 addition & 0 deletions
1
content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-general
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../modulino-nodes/modulino-thermo/tutorials/how-general |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to link to Thermo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general live in the thermo @jhansson-ard is there a better way?