Skip to content

Commit 52c5e94

Browse files
add README.md and docs/README.md
1 parent d5de8d9 commit 52c5e94

File tree

2 files changed

+180
-0
lines changed

2 files changed

+180
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# 🧩 Arduino Modulino® Library
2+
3+
The Arduino Modulino® Library simplifies the integration and management of Modulino® modules on Arduino boards.
4+
5+
A Modulino® is a compact, modular electronic device that connects easily to Arduino via the Qwiic connector and communicates using the I2C (`Wire`) protocol. These modules include sensors, actuators, and more.
6+
7+
## Hardware Compatibility
8+
This library is compatible with all Arduino boards that feature an I2C interface (`Wire`).
9+
10+
📖 For more information about this library please read the documentation [here](./docs/).
11+
12+
## Support and Contributions
13+
If you find this library helpful, consider supporting us through [donations](https://www.arduino.cc/en/donate/), [sponsorship](https://github.com/sponsors/arduino) or check out our [store](https://store.arduino.cc/).

docs/readme.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Arduino Modulino® Library
2+
3+
The **Modulino** library is designed to simplify integration with various Modulino. It supports a variety of modules, such as motion sensors, buttons, buzzers, LED displays, and more, all through an I2C (`Wire`) interface.
4+
5+
## Hardware Compatibility
6+
7+
The library is compatible with Arduino boards that support I2C (`Wire`) communication.
8+
9+
Each Modulino has a fixed I2C address assigned by default. If you wish to change the I2C address, you can refer to the [Utilities](#utilities) section.
10+
11+
## Main Features
12+
13+
The **Modulino** library supports the following hardware modules:
14+
15+
- **Buttons (`ModulinoButtons`)**: Read the state of buttons and control the associated LEDs.
16+
- **Buzzer (`ModulinoBuzzer`)**: Activate and deactivate the buzzer and set its frequency.
17+
- **LEDs (`ModulinoPixels`)**: Control RGB LEDs with customizable display modes.
18+
- **Knob (`ModulinoKnob`)**: Read the value of a rotary encoder.
19+
- **Motion (`ModulinoMovement`)**: Interface with the LSM6DSOX IMU sensor to get acceleration values.
20+
- **Temperature & Humidity (`ModulinoThermo`)**: Get temperature and humidity readings from the HS300x sensor.
21+
- **Pressure (`ModulinoPressure`)**: Get atmospheric pressure readings from the LPS22HB sensor.
22+
23+
## Library Initialization
24+
25+
To initialize the **Modulino** library, include the header file and call the `begin()` method. This will set up the I2C communication and prepare the library for use with the modules.
26+
27+
```cpp
28+
#include <Modulino.h>
29+
Modulino.begin(); // Initialize the Modulino library
30+
```
31+
32+
## Supported Modules
33+
34+
You can initialize a Modulino board easily. The basic setup requires just a call to the `begin()` method for each module. For example:
35+
36+
```cpp
37+
ModulinoType modulino_name;
38+
modulino_name.begin(); // Initialize the ModulinoType module
39+
```
40+
41+
### ModulinoButtons
42+
Manages the state of three buttons and controls their associated LED states. You can read the state of each button and send commands to turn the LEDs on/off.
43+
44+
```cpp
45+
ModulinoButtons buttons;
46+
buttons.begin();
47+
buttons.setLeds(true, false, true); // Turn on LED 1 and LED 3
48+
```
49+
50+
### ModulinoBuzzer
51+
Allows you to emit sounds through the buzzer. You can set the frequency and duration of the sound.
52+
53+
```cpp
54+
ModulinoBuzzer buzzer;
55+
buzzer.begin();
56+
buzzer.tone(440, 1000); // 440Hz frequency for 1000ms
57+
```
58+
59+
### ModulinoPixels
60+
Controls an array of 8 RGB LEDs, allowing you to set the colors and brightness. You can also clear individual LEDs or the entire array.
61+
62+
```cpp
63+
ModulinoPixels leds;
64+
leds.set(0, ModulinoColor(255, 0, 0)); // Set the first LED (Position: 0) to red
65+
leds.show(); // Display the LEDs
66+
```
67+
68+
### ModulinoKnob
69+
Manages a rotary encoder, allowing you to read the potentiometer value and check if the knob is pressed.
70+
71+
```cpp
72+
ModulinoKnob knob;
73+
knob.begin();
74+
int16_t value = knob.get(); // Get the value of the encoder
75+
```
76+
77+
### ModulinoMovement
78+
Interfaces with the LSM6DSOX IMU sensor to get acceleration readings.
79+
80+
```cpp
81+
ModulinoMovement movement;
82+
movement.begin();
83+
float x = movement.getX();
84+
```
85+
86+
### ModulinoThermo
87+
Reads temperature and humidity data from the HS300x sensor.
88+
89+
```cpp
90+
ModulinoThermo thermo;
91+
thermo.begin();
92+
float temperature = thermo.getTemperature();
93+
float humidity = thermo.getHumidity();
94+
```
95+
96+
### ModulinoPressure
97+
Reads atmospheric pressure data from the LPS22HB sensor.
98+
99+
```cpp
100+
ModulinoPressure pressure;
101+
pressure.begin();
102+
float pressureValue = pressure.getPressure();
103+
```
104+
105+
## Example Usage
106+
107+
Here’s an example of how to use some Modulino in a program:
108+
109+
```cpp
110+
// This sketch demonstrates how to use the Modulino library to control buttons, LEDs, and a buzzer.
111+
// It listens for a button press (Button A), turns on the LED 0, and plays a sound through the buzzer when pressed.
112+
113+
#include <Modulino.h>
114+
115+
ModulinoButtons buttons; // Declare a Buttons Modulino
116+
ModulinoPixels leds; // Declare a Pixels Modulino
117+
ModulinoBuzzer buzzer; // Declare a Buzzer Modulino
118+
119+
int frequency = 440; // Set frequency to 440Hz
120+
int duration = 1000; // Set duration to 1000ms
121+
122+
void setup() {
123+
Serial.begin(9600);
124+
125+
Modulino.begin(); // Initialize the Modulino library
126+
127+
buttons.begin(); // Initialize the Buttons module
128+
leds.begin(); // Initialize the Pixels module
129+
buzzer.begin(); // Initialize the Buzzer module
130+
}
131+
132+
void loop() {
133+
if (buttons.update()) { // Update the button states
134+
if (buttons.isPressed(0)) { // Check if Button A (button 0) is pressed
135+
Serial.println("Button A pressed!");
136+
leds.set(0, RED); // Turn on LED 0 to red
137+
leds.show();
138+
139+
buzzer.tone(frequency, duration); // Play buzzer sound with the specified frequency and duration
140+
delay(duration);
141+
} else {
142+
leds.clear(0); // Turn off LED 0
143+
leds.show();
144+
}
145+
}
146+
}
147+
```
148+
149+
## Examples
150+
151+
The examples folder is organized by Modulino type. Each module has its own folder with example sketches that demonstrate both basic and advanced usage (where applicable).
152+
153+
You can explore the examples [here](../examples).
154+
155+
### Utilities
156+
157+
In the [Utilities](../examples/Utilities) folder, you will find programs designed to help you manage and manipulate the Modulino:
158+
159+
- [AddressChanger](../examples/Utilities/AddressChanger/): This program allows you to change the I2C address of a Modulino module. It’s helpful when you need to reassign addresses to avoid conflicts or organize your I2C network.
160+
161+
## API
162+
163+
The API documentation can be found [here](./api.md).
164+
165+
## License
166+
167+
This library is released under the [LGPLv2.1 license](../LICENSE).

0 commit comments

Comments
 (0)