#include <FastLED.h>
#include "NumberPatterns.h"
#include "NumberPatterns1.h"
int value_1 = -1; // Initialize value_1 as -1 to indicate no value received yet
int value_2 = -1; // Initialize value_2 as -1 to indicate no value received yet
String inputBuffer = ""; // Buffer to store incoming serial data
#define NUM_LEDS 48 // Change this to match the number of LEDs in your strip
#define DATA_PIN 8 // Change this to match the data pin connected to your strip
#define NUM_LEDS_1 48 // Change this to match the number of LEDs in your strip
#define DATA_PIN_1 10 // Change this to match the data pin connected to your strip
CRGB leds[NUM_LEDS];
CRGB leds_1[NUM_LEDS_1];
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud
Serial.print("Test");
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, DATA_PIN_1, GRB>(leds_1, NUM_LEDS_1);
}
void loop() {
// fill_solid(leds, NUM_LEDS, CRGB::White);
// FastLED.show();
while (Serial.available()) {
char inputChar = Serial.read(); // Read a character from serial
if (inputChar == '\n') {
// End of input, split the buffer into one or two integers
if (inputBuffer.length() >= 1 && inputBuffer.length() <= 2) {
if (inputBuffer.length() == 1) {
value_1 = -1; // Set value_1 to -1
value_2 = inputBuffer.charAt(0) - '0';
} else {
value_1 = inputBuffer.charAt(0) - '0';
value_2 = inputBuffer.charAt(1) - '0';
}
Serial.print("Value 1: ");
Serial.println(value_1);
Serial.print("Value 2: ");
Serial.println(value_2);
displayNumberPattern1(value_2);
displayNumberPattern(value_1);
} else {
// Invalid input length
Serial.println("Invalid input length. Input should be 1 or 2 digits.");
}
// Reset the input buffer
inputBuffer = "";
} else if (isdigit(inputChar)) {
// Append valid digits to the buffer
inputBuffer += inputChar;
} else if (inputChar == '0') {
// If '0' is received, reset values and buffer
value_1 = -1;
value_2 = -1;
inputBuffer = "";
}
}
}