-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathSimple_Animation.ino
57 lines (46 loc) · 1.15 KB
/
Simple_Animation.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Modulino Pixels - Simple Animation
*
* This example code is in the public domain.
* Copyright (c) 2025 Arduino
* SPDX-License-Identifier: MPL-2.0
*/
#include <Arduino_Modulino.h>
// Create a ModulinoPixels object for the LED array
ModulinoPixels leds;
// Define a custom color for turning off LEDs
ModulinoColor OFF(0, 0, 0);
int brightness = 25;
void setup() {
// Initialize Modulino I2C communication
Modulino.begin();
// Detect and connect to pixels module
leds.begin();
}
void loop() {
// Light up LEDs in different colors
// Available colors: RED, BLUE, GREEN, VIOLET, WHITE
for (int i = 0; i < 8; i++) {
if (i == 0 || i == 1) {
setPixel(i, RED);
} else if (i == 2 || i == 3) {
setPixel(i, BLUE);
} else if(i == 4 || i == 5){
setPixel(i, GREEN);
} else if(i == 6 || i == 7){
setPixel(i, VIOLET);
} else if (i == 7 || i == 8) {
setPixel(i, WHITE);
}
delay(25);
}
// Turn off all LEDs one by one
for (int i = 0; i < 8; i++) {
setPixel(i, OFF);
delay(25);
}
}
void setPixel(int pixel, ModulinoColor color) {
leds.set(pixel, color, brightness);
leds.show();
}