I want to communicate between 2 Pi Pico's using I2C. I want to do program these with the Arduino IDE. I have tried using Wire.h and some examples I found online. However, they don't seem to be able to connect to each other.
This is my Master code:
#include "Wire.h"
void setup() {
Wire.begin();
Serial.begin(9600);
bool setSDA(1);
bool setSCL(2);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
}
void loop() {
Wire.requestFrom(8, 6);
Serial.println("Waiting...");
while (Wire.available()) {
char c = Wire.read();
Serial.print(c); }
delay(500);
}
This is my slave code:
#include "Wire.h"
void setup() {
Wire.begin(8);
Wire.onRequest(requestEvent);
Serial.begin();
bool setSDA(1);
bool setSCL(2);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
}
void loop() {
delay(100);
Serial.println("Recieving...");
}
void requestEvent() {
Wire.write("hello ");
}
What am I doing wrong?