diff --git a/APL_Master/README.md b/APL_Master/README.md index f7a9d96..66ab445 100644 --- a/APL_Master/README.md +++ b/APL_Master/README.md @@ -1 +1,13 @@ -# Architektoniczne perełki Lublina - Master \ No newline at end of file +# 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` \ No newline at end of file diff --git a/APL_Master/platformio.ini b/APL_Master/platformio.ini index 86818e0..e45e6ea 100644 --- a/APL_Master/platformio.ini +++ b/APL_Master/platformio.ini @@ -12,5 +12,6 @@ platform = espressif32 board = esp32dev framework = arduino - monitor_speed = 115200 + +lib_deps = fastled/FastLED@^3.10.3 diff --git a/APL_Master/src/main.cpp b/APL_Master/src/main.cpp index 37a1561..9feee3d 100644 --- a/APL_Master/src/main.cpp +++ b/APL_Master/src/main.cpp @@ -1,11 +1,53 @@ #include +#include +#include + +#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(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 + } +} \ No newline at end of file diff --git a/APL_Slave_1/README.md b/APL_Slave_1/README.md index 0a16a38..a59945c 100644 --- a/APL_Slave_1/README.md +++ b/APL_Slave_1/README.md @@ -1 +1,8 @@ # Architektoniczne perełki Lublina - Slave 1 + +## I2C +Pins: + - SDA -> 21 + - SCL -> 22 + +Address: 0x08 \ No newline at end of file diff --git a/APL_Slave_1/src/main.cpp b/APL_Slave_1/src/main.cpp index b1cef02..895c624 100644 --- a/APL_Slave_1/src/main.cpp +++ b/APL_Slave_1/src/main.cpp @@ -1,10 +1,29 @@ #include +#include + +#define SDA_PIN 21 +#define SCL_PIN 22 + +#define SLAVE_ADDRESS 0x08 + +void requestEvent(); void setup() { Serial.begin(115200); + + Wire.begin(SDA_PIN, SCL_PIN, SLAVE_ADDRESS); // Initialize I2C with specified SDA and SCL pins + + Wire.onRequest(requestEvent); } void loop() { } + +void requestEvent() +{ + // TODO: Send data to the master when requested + Serial.println("Master requested data from Slave."); + Wire.write("Hello from Slave!"); +} \ No newline at end of file diff --git a/APL_Slave_2/README.md b/APL_Slave_2/README.md index 20462a5..cdb1853 100644 --- a/APL_Slave_2/README.md +++ b/APL_Slave_2/README.md @@ -1 +1,8 @@ -# Architektoniczne perełki Lublina - Slave 2 \ No newline at end of file +# Architektoniczne perełki Lublina - Slave 2 + +## I2C +Pins: + - SDA -> 21 + - SCL -> 22 + +Address: 0x09 \ No newline at end of file diff --git a/APL_Slave_2/src/main.cpp b/APL_Slave_2/src/main.cpp index 37a1561..9c79bed 100644 --- a/APL_Slave_2/src/main.cpp +++ b/APL_Slave_2/src/main.cpp @@ -1,11 +1,29 @@ #include +#include + +#define SDA_PIN 21 +#define SCL_PIN 22 + +#define SLAVE_ADDRESS 0x09 + +void requestEvent(); void setup() { Serial.begin(115200); + + Wire.begin(SDA_PIN, SCL_PIN, SLAVE_ADDRESS); // Initialize I2C with specified SDA and SCL pins + + Wire.onRequest(requestEvent); } void loop() { - // put your main code here, to run repeatedly: } + +void requestEvent() +{ + // TODO: Send data to the master when requested + Serial.println("Master requested data from Slave."); + Wire.write("Hello from Slave!"); +} \ No newline at end of file diff --git a/APL_Slave_3/README.md b/APL_Slave_3/README.md index b88f3af..ca39350 100644 --- a/APL_Slave_3/README.md +++ b/APL_Slave_3/README.md @@ -1 +1,8 @@ -# Architektoniczne perełki Lublina - Slave 3 \ No newline at end of file +# Architektoniczne perełki Lublina - Slave 3 + +## I2C +Pins: + - SDA -> 21 + - SCL -> 22 + +Address: 0x0A \ No newline at end of file diff --git a/APL_Slave_3/src/main.cpp b/APL_Slave_3/src/main.cpp index f76fc99..510f019 100644 --- a/APL_Slave_3/src/main.cpp +++ b/APL_Slave_3/src/main.cpp @@ -1,11 +1,29 @@ #include +#include + +#define SDA_PIN 21 +#define SCL_PIN 22 + +#define SLAVE_ADDRESS 0x0A + +void requestEvent(); void setup() { Serial.begin(115200); + + Wire.begin(SDA_PIN, SCL_PIN, SLAVE_ADDRESS); // Initialize I2C with specified SDA and SCL pins + + Wire.onRequest(requestEvent); } void loop() { - // put your main code here, to run repeatedly: +} + +void requestEvent() +{ + // TODO: Send data to the master when requested + Serial.println("Master requested data from Slave."); + Wire.write("Hello from Slave!"); } \ No newline at end of file diff --git a/APL_Slave_4/README.md b/APL_Slave_4/README.md index a90f8e7..8fd5c9b 100644 --- a/APL_Slave_4/README.md +++ b/APL_Slave_4/README.md @@ -1 +1,8 @@ -# Architektoniczne perełki Lublina - Slave 4 \ No newline at end of file +# Architektoniczne perełki Lublina - Slave 4 + +## I2C +Pins: + - SDA -> 21 + - SCL -> 22 + +Address: 0x0B \ No newline at end of file diff --git a/APL_Slave_4/src/main.cpp b/APL_Slave_4/src/main.cpp index b1cef02..b2b60bf 100644 --- a/APL_Slave_4/src/main.cpp +++ b/APL_Slave_4/src/main.cpp @@ -1,10 +1,29 @@ #include +#include + +#define SDA_PIN 21 +#define SCL_PIN 22 + +#define SLAVE_ADDRESS 0x0B + +void requestEvent(); void setup() { Serial.begin(115200); + + Wire.begin(SDA_PIN, SCL_PIN, SLAVE_ADDRESS); // Initialize I2C with specified SDA and SCL pins + + Wire.onRequest(requestEvent); } void loop() { } + +void requestEvent() +{ + // TODO: Send data to the master when requested + Serial.println("Master requested data from Slave."); + Wire.write("Hello from Slave!"); +} \ No newline at end of file diff --git a/APL_Slave_5/README.md b/APL_Slave_5/README.md index 44d036d..2299fc1 100644 --- a/APL_Slave_5/README.md +++ b/APL_Slave_5/README.md @@ -1 +1,8 @@ -# Architektoniczne perełki Lublina - Slave 5 \ No newline at end of file +# Architektoniczne perełki Lublina - Slave 5 + +## I2C +Pins: + - SDA -> 21 + - SCL -> 22 + +Address: 0x0C \ No newline at end of file diff --git a/APL_Slave_5/src/main.cpp b/APL_Slave_5/src/main.cpp index b1cef02..ef13d54 100644 --- a/APL_Slave_5/src/main.cpp +++ b/APL_Slave_5/src/main.cpp @@ -1,10 +1,29 @@ #include +#include + +#define SDA_PIN 21 +#define SCL_PIN 22 + +#define SLAVE_ADDRESS 0x0C + +void requestEvent(); void setup() { Serial.begin(115200); + + Wire.begin(SDA_PIN, SCL_PIN, SLAVE_ADDRESS); // Initialize I2C with specified SDA and SCL pins + + Wire.onRequest(requestEvent); } void loop() { } + +void requestEvent() +{ + // TODO: Send data to the master when requested + Serial.println("Master requested data from Slave."); + Wire.write("Hello from Slave!"); +} \ No newline at end of file