Skip to content

Commit 1bdc76a

Browse files
committed
new examples and folder structure
1 parent 4f10376 commit 1bdc76a

File tree

19 files changed

+228
-0
lines changed

19 files changed

+228
-0
lines changed

examples/Modulino_Buttons/.DS_Store

6 KB
Binary file not shown.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <Modulino.h>
2+
3+
ModulinoButtons buttons;
4+
5+
bool button_a = false;
6+
bool button_b = false;
7+
bool button_c = false;
8+
9+
void setup() {
10+
Serial.begin(9600);
11+
Modulino.begin();
12+
buttons.begin();
13+
//function to control the LEDs on top of each button
14+
buttons.setLeds(true, true, true);
15+
}
16+
void loop() {
17+
//request new data from the Modulino buttons
18+
if (buttons.update()) {
19+
//Check if the buttons has been pressed
20+
if (buttons.isPressed(0)) {
21+
Serial.println("Button A pressed!");
22+
} else if (buttons.isPressed(1)) {
23+
Serial.println("Button B pressed!");
24+
} else if (buttons.isPressed(2)) {
25+
Serial.println("Button C pressed!");
26+
}
27+
}
28+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <Modulino.h>
2+
3+
ModulinoBuzzer buzzer;
4+
5+
int frequency = 440;
6+
int duration = 1000;
7+
8+
void setup(){
9+
Modulino.begin();
10+
buzzer.begin();
11+
}
12+
13+
void loop(){
14+
15+
buzzer.tone(frequency, duration);
16+
delay(1000);
17+
buzzer.tone(0, duration);
18+
delay(1000);
19+
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <Modulino.h>
2+
3+
ModulinoBuzzer buzzer;
4+
5+
int melody[] = { 262, 196, 196, 220, 196, 0, 247, 262 };
6+
7+
void setup() {
8+
Modulino.begin();
9+
buzzer.begin();
10+
}
11+
12+
void loop() {
13+
14+
for (int i = 0; i < 8; i++) {
15+
int note = melody[i];
16+
17+
buzzer.tone(note, 250);
18+
delay(250);
19+
20+
}
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "Modulino.h"
2+
3+
ModulinoDistance distance;
4+
5+
void setup() {
6+
Serial.begin(9600);
7+
Modulino.begin();
8+
distance.begin();
9+
}
10+
11+
void loop() {
12+
int measure = distance.get();
13+
Serial.println(measure);
14+
delay(10);
15+
}

examples/Modulino_Knob/.DS_Store

6 KB
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <Modulino.h>
2+
3+
ModulinoKnob knob;
4+
5+
void setup() {
6+
Serial.begin(9600);
7+
Modulino.begin();
8+
knob.begin();
9+
}
10+
11+
void loop(){
12+
int position = knob.get();
13+
bool click = knob.isPressed();
14+
15+
Serial.print("Current position is: ");
16+
Serial.println(position);
17+
18+
if(click){
19+
Serial.println("Clicked!");
20+
}
21+
22+
}

examples/EncoderSetter/EncoderSetter.ino renamed to examples/Modulino_Knob/EncoderSetter/EncoderSetter.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void setup() {
1515

1616
void loop() {
1717
int value = encoder.get();
18+
//Reset the position of the encoder with the set function
1819
if (value > 100 || value < 0) {
1920
encoder.set(0);
2021
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "Modulino.h"
2+
3+
ModulinoMovement movement;
4+
5+
float x;
6+
float y;
7+
float z;
8+
9+
void setup() {
10+
Serial.begin(9600);
11+
Modulino.begin();
12+
movement.begin();
13+
}
14+
15+
void loop() {
16+
movement.update();
17+
18+
x = movement.getX();
19+
y = movement.getY();
20+
z = movement.getZ();
21+
22+
Serial.print("Movement data: ");
23+
Serial.print("x ");
24+
Serial.print(x, 3);
25+
Serial.print(" y ");
26+
Serial.print(y, 3);
27+
Serial.print(" z ");
28+
Serial.println(z, 3);
29+
}

0 commit comments

Comments
 (0)