feat: added configurations for i2c communication between devices
This commit is contained in:
@@ -1 +1,8 @@
|
||||
# Architektoniczne perełki Lublina - Slave 4
|
||||
# Architektoniczne perełki Lublina - Slave 4
|
||||
|
||||
## I2C
|
||||
Pins:
|
||||
- SDA -> 21
|
||||
- SCL -> 22
|
||||
|
||||
Address: 0x0B
|
||||
@@ -1,10 +1,29 @@
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
|
||||
#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!");
|
||||
}
|
||||
Reference in New Issue
Block a user