1
0
mirror of https://github.com/taigrr/arduinolibs synced 2025-01-18 04:33:12 -08:00

Support class for Charlieplexing large numbers of LED's

This commit is contained in:
Rhys Weatherley
2012-05-31 10:47:52 +10:00
parent 4b4eeee672
commit 7d124dfb85
18 changed files with 2108 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
/* This example is placed into the public domain */
#include <Charlieplex.h>
byte pins[3] = {9, 10, 11};
Charlieplex charlie(pins, sizeof(pins));
int previous = 1;
int current = 0;
int step = 1;
unsigned long lastTime;
void setup() {
lastTime = millis();
charlie.setLed(current, true);
charlie.setPwmLed(previous, 64);
}
void loop() {
if ((millis() - lastTime) >= 100) {
charlie.setLed(previous, false);
charlie.setPwmLed(current, 64);
previous = current;
current += step;
if (current < 0) {
current = 1;
step = 1;
} else if (current >= charlie.count()) {
current = charlie.count() - 2;
step = -1;
}
charlie.setLed(current, true);
lastTime += 100;
}
charlie.loop();
}