feat: added configurations for i2c communication between devices
This commit is contained in:
+13
-1
@@ -1 +1,13 @@
|
||||
# Architektoniczne perełki Lublina - Master
|
||||
# Architektoniczne perełki Lublina - Master
|
||||
|
||||
## I2C
|
||||
Pins:
|
||||
- SDA -> 21
|
||||
- SCL -> 22
|
||||
|
||||
Addresses:
|
||||
- Slave 1 -> `0x08`
|
||||
- Slave 2 -> `0x09`
|
||||
- Slave 3 -> `0x0A`
|
||||
- Slave 4 -> `0x0B`
|
||||
- Slave 5 -> `0x0C`
|
||||
@@ -12,5 +12,6 @@
|
||||
platform = espressif32
|
||||
board = esp32dev
|
||||
framework = arduino
|
||||
|
||||
monitor_speed = 115200
|
||||
|
||||
lib_deps = fastled/FastLED@^3.10.3
|
||||
|
||||
@@ -1,11 +1,53 @@
|
||||
#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:
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user