#include <Arduino.h>
#include <vector>
#include <random>
const int potPin = 34; // pin of the potentiometer
const int slidePin = 35; // pin of the potentiometer
const int width = 32;
const int height = 8;
const int maxBrightness = 4095;
#include "LEDMatrix.h"
#include "rainAnimation.h"
#include "starsAnimation.h"
#include "matrixAnimation.h"
unsigned long lastFrameTime = 0;
std::function<std::vector<int>(int, int, int)> currentEffect;
// Creates an 8x8 LED matrix with I2C address 0x40 and max brightness of 4095
LEDMatrix matrix(width, height, 0x40, maxBrightness);
void setup() {
Serial.begin(115200);
currentEffect = matrixAnimation;
}
void loop() {
int bri = analogRead(slidePin);
matrix.setBrightness(bri, 0);
unsigned long currentTime = millis();
// update every 1 / 30 seconds
if (currentTime - lastFrameTime > 1000 / 24) {
if (currentEffect) {
matrix.draw(currentEffect(width, height, maxBrightness));
} else {
matrix.fillScreen(0);
}
matrix.toSerial();
lastFrameTime = currentTime;
}
}