Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
- name: Arduino_HS300x
- name: Button2
- name: ArduinoGraphics
- name: Arduino_LTR381RGB

enable-deltas-report: true
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
Expand Down
22 changes: 22 additions & 0 deletions examples/Modulino_Joystick/Joystick_Basic/Joystick_Basic.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "Modulino.h"

ModulinoJoystick joystick;

void setup() {
Serial.begin(9600);
Modulino.begin();
joystick.begin();
}

void loop() {
joystick.update();

if(joystick.isPressed()) {
Serial.println("Pressed");
}

Serial.print("x,y: ");
Serial.print(joystick.getX());
Serial.print(", ");
Serial.println(joystick.getY());
}
45 changes: 45 additions & 0 deletions examples/Modulino_LatchRelay/LatchRelay_Basic/LatchRelay_Basic.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Modulino Latch Relay - Basic
*
* This example code is in the public domain.
* Copyright (c) 2025 Arduino
* SPDX-License-Identifier: MPL-2.0
*/

#include <Modulino.h>

ModulinoLatchRelay relay;

void setup() {
// put your setup code here, to run once:
Modulino.begin();
Serial.begin(115200);
relay.begin();
}

void loop() {
// put your main code here, to run repeatedly:
if (Serial.available()) {
char c = Serial.read();
switch (c) {
case 's':
relay.set();
break;
case 'r':
relay.reset();
break;
case 'x':
auto status = relay.getStatus();
if (status == 0) {
Serial.println("Relay OFF");
}
if (status == 1) {
Serial.println("Relay ON");
}
if (status < 0) {
Serial.println("Relay status unknown");
}
break;
}
}
}
151 changes: 151 additions & 0 deletions examples/Modulino_Light/ColorDetection/ColorDetection.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#include "Modulino.h"

ModulinoLight light;

// before to run this sketch, change the encoders addresses in order to use more than one encoder
// and set the addresses in the constructor as shown below
ModulinoKnob knob_green;
ModulinoKnob knob_red(0x09);
ModulinoKnob knob_blue(0x0A);
ModulinoPixels leds;


int brightness = 100;
int red = 0;
int green = 0;
int blue = 0;


void setup() {
Serial.begin(9600);
Modulino.begin();
knob_green.begin();
knob_red.begin();
knob_blue.begin();

// set knobs initial positions to 0
knob_red.set(0);
knob_green.set(0);
knob_blue.set(0);
light.begin();
leds.begin();
}

unsigned long start = millis();
void loop() {
knobPressed();
readColors();
updatesColors();
}

void readColors() {
if (red > 255) {
red = 255;
knob_red.set(red);
} else if (red < 0) {
red = 0;
knob_red.set(red);
}

if (green > 255) {
green = 255;
knob_green.set(green);
} else if (green < 0) {
green = 0;
knob_green.set(green);
}

if (blue > 255) {
blue = 255;
knob_blue.set(blue);
} else if (blue < 0) {
blue = 0;
knob_red.set(blue);
}
}

void knobPressed() {
red = knob_red.get();
green = knob_green.get();
blue = knob_blue.get();
bool red_click = knob_red.isPressed();
bool green_click = knob_green.isPressed();
bool blue_click = knob_blue.isPressed();

if (red_click) {
red = 255;
knob_red.set(red);
}

if (green_click) {
green = 255;
knob_green.set(green);
}

if (blue_click) {
blue = 255;
knob_blue.set(blue);
}

if (green_click && blue_click && red_click ) {
red = 0;
knob_red.set(red);
green = 0;
knob_green.set(green);
blue = 0;
knob_blue.set(blue);
} else if (red_click && green_click) {
red = 255;
knob_red.set(red);
green = 255;
knob_green.set(green);
blue = 0;
knob_blue.set(blue);
} else if (red_click && blue_click) {
red = 255;
knob_red.set(red);
green = 0;
knob_green.set(green);
blue = 255;
knob_blue.set(blue);
} else if (green_click && blue_click) {
red = 0;
knob_red.set(red);
green = 255;
knob_green.set(green);
blue = 255;
knob_blue.set(blue);
}
}

void updatesColors() {
ModulinoColor COLOR(red, green, blue);
for (int l = 0; l < 8; l++) {
leds.set(l, COLOR, brightness);
leds.show();
}
light.update();

if (millis() - start > 1000) {
char buffer [50];
int n, a = 3;
n = sprintf (buffer, "%03d", red);

Serial.print("Red:\t");
Serial.print(buffer);
n = sprintf (buffer, "%03d", green);
Serial.print("\tGreen:\t");
Serial.print(buffer);
n = sprintf (buffer, "%03d", blue);
Serial.print("\tBlue:\t");
Serial.print(buffer);

ModulinoColor color = light.getColor();
String colorName = light.getColorApproximate();
Serial.print("\tColor near to:\t");
Serial.print(colorName);
Serial.println();

start = millis();
}
}
39 changes: 39 additions & 0 deletions examples/Modulino_Light/Light_Basic/Light_Basic.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "Modulino.h"

ModulinoLight light;

int lux;
int ir;

void setup() {
Serial.begin(9600);
Modulino.begin();
light.begin();
}

void loop() {
light.update();
ModulinoColor color = light.getColor();
String colorName = light.getColorApproximate();
Serial.print("Color near to: ");
Serial.print(colorName);

int r = (0xFF000000 & color) >> 24;
int g = (0x00FF0000 & color) >> 16;
int b = (0x0000FF00 & color) >> 8;

lux = light.getAL();
ir = light.getIR();

Serial.print("\tlight data: ");
Serial.print("\tRed:\t");
Serial.print(r);
Serial.print("\tGreen:\t");
Serial.print(g);
Serial.print("\tBlue:\t");
Serial.print(b);
Serial.print("\tLux:\t");
Serial.print(lux);
Serial.print("\tIR\t");
Serial.println(ir);
}
27 changes: 27 additions & 0 deletions examples/Modulino_Vibro/Vibro_Basic/Vibro_Basic.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "Modulino.h"

ModulinoVibro vibro;

void setup() {
Modulino.begin();
vibro.begin();
}

void loop() {
// Cycle through vibration intensities from GENTLE to MAXIMUM
// Each intensity increases by 5, lasting 1 seconds each
for (int intensity = GENTLE; intensity <= MAXIMUM; intensity += 5) {
Serial.println(intensity);
vibro.on(1000, true, intensity);
vibro.off();
delay(100);
}

// Two vibration of one second separated by a long pause
// using the blocking on call
delay(1000);
vibro.on(1000);
delay(5000);
vibro.on(1000);
delay(1000);
}
6 changes: 6 additions & 0 deletions examples/Utilities/AddressChanger/AddressChanger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,19 @@ String pinstrapToName(uint8_t pinstrap) {
switch (pinstrap) {
case 0x3C:
return "Buzzer";
case 0x58:
return "Joystick";
case 0x7C:
return "Buttons";
case 0x28:
return "Opto Relay";
case 0x76:
case 0x74:
return "Encoder";
case 0x6C:
return "Smartleds";
case 0x70:
return "Vibro";
}
return "UNKNOWN";
}
Expand Down
Loading
Loading