Files
architektoniczne_perelki_lu…/APL_Master/src/main.cpp
T

56 lines
1.4 KiB
C++

#include <Arduino.h>
#include <Wire.h>
#include <FastLED.h>
#define SDA_PIN 21
#define SCL_PIN 22
#define SLAVE_ONE_ADDRESS 0x08
#define SLAVE_TWO_ADDRESS 0x09
#define SLAVE_THREE_ADDRESS 0x0A
#define SLAVE_FOUR_ADDRESS 0x0B
#define SLAVE_FIVE_ADDRESS 0x0C
#define LED_DATA_PIN 5
#define LED_COUNT 29
#define BRIGHTNESS 64
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[LED_COUNT];
const CRGB SUCCESS_COLOR = CRGB::Green;
const CRGB ERROR_COLOR = CRGB::Red;
void testLedStrip();
void setup()
{
Wire.begin(SDA_PIN, SCL_PIN);
Serial.begin(115200);
// Initialize FastLED with the specified LED type, data pin, and LED count
FastLED.addLeds<LED_TYPE, LED_DATA_PIN, COLOR_ORDER>(leds, LED_COUNT).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
testLedStrip();
}
void loop()
{
// put your main code here, to run repeatedly:
// TODO: Implement the main loop logic for I2C communication with slave devices
// TODO: Implement the logic to control the LED strip based on the received data from slave devices
// TODO: Send informations to PC via Serial communication, needs to be implemented based on the previous code snippets.
}
void testLedStrip()
{
// Test the LED strip by turning on each LED one by one
for (int i = 0; i < LED_COUNT; i++)
{
leds[i] = SUCCESS_COLOR; // Set the LED to green
FastLED.show();
delay(100); // Wait for a short duration
leds[i] = CRGB::Black; // Turn off the LED
}
}