#include <FastLED.h>
#define LED_PIN1 26
#define LED_PIN2 25
#define bt_mais_um_a 15
#define bt_mais_dez_a 2
#define bt_mais_um_b 4
#define bt_mais_dez_b 5
#define NUM_LEDS 28
CRGB leds1[NUM_LEDS];
CRGB leds2[NUM_LEDS];
int val_bt_mais_um_a = 0;
int jaExecutou1 = 0;
int cont = 0;
int ligaLeds[10] = {
0b1111111111111111111111110000,
0b1111000000000000000011110000, // 1
0b0000111111110000111111111111, // 2
0b1111111100000000111111111111, // 3
0b1111000000001111000011111111, // 4
0b1111111100001111111100001111, // 5
0b1111111111111111111100001111, // 6
0b1111000000000000111111110000, // 7
0b1111111111111111111111111111, // 8
0b1111111100001111111111111111, // 9
};
void mostrarUniHor(int numero) {
for (int i = 0; i < NUM_LEDS; ++i) {
if (ligaLeds[numero] & (1 << i)) {
leds2[i] = CRGB(0, 0, 255);
} else {
leds2[i] = CRGB(0, 0, 0);
}
}
FastLED.show();
}
void mostrarDezHor(int numero) {
for (int i = 0; i < NUM_LEDS; ++i) {
if (ligaLeds[numero] & (1 << i)) {
leds1[i] = CRGB(0, 0, 255);
} else {
leds1[i] = CRGB(0, 0, 0);
}
}
FastLED.show();
}
void setup() {
pinMode(bt_mais_um_a, INPUT);
pinMode(bt_mais_dez_a, INPUT);
pinMode(bt_mais_um_b, INPUT);
pinMode(bt_mais_dez_b, INPUT);
FastLED.addLeds<WS2812, LED_PIN1, GRB>(leds1, NUM_LEDS);
FastLED.addLeds<WS2812, LED_PIN2, GRB>(leds2, NUM_LEDS);
}
void loop() {
val_bt_mais_um_a = digitalRead(bt_mais_um_a);
if (val_bt_mais_um_a == HIGH && jaExecutou1 == LOW){
jaExecutou1 = HIGH;
cont++;
}
else if (val_bt_mais_um_a == LOW){
jaExecutou1 = LOW;
}
mostrarDezHor(int(cont / 10));
mostrarUniHor(cont % 10);
}