Hi, long time reader, first time poster.
I purchased a Teensy 4.1 with Audio Shield a while ago and it has been perfect. I recently set it up to accept I2C commands from an Arduino Portenta instead of Serial commands however I cannot get it to function as a slave.
Both the Arduino and the Teensy I2C are 3.3v and I use 4.7K pull ups between the connection.
I loaded the Master script on the Portenta, and the slave script on the teensy to no effect, the teensy reports via serial console that it is just "Waiting..." (see script) but reversing that, it works with the Teensy as the master and the Portenta as the slave. I am at a bit of a loss, any ideas on what I am doing wrong?
Master Script
Slave Script
Any help or thoughts are greatly appreciated
I purchased a Teensy 4.1 with Audio Shield a while ago and it has been perfect. I recently set it up to accept I2C commands from an Arduino Portenta instead of Serial commands however I cannot get it to function as a slave.
Both the Arduino and the Teensy I2C are 3.3v and I use 4.7K pull ups between the connection.
I loaded the Master script on the Portenta, and the slave script on the teensy to no effect, the teensy reports via serial console that it is just "Waiting..." (see script) but reversing that, it works with the Teensy as the master and the Portenta as the slave. I am at a bit of a loss, any ideas on what I am doing wrong?
Master Script
Code:
#include <Wire.h>
int led = LED_BUILTIN;
void setup()
{
pinMode(led, OUTPUT);
Wire.begin();
}
byte x = 0;
void loop()
{
digitalWrite(led, HIGH);
Wire.beginTransmission(0x10);
Wire.write("x is ");
Wire.write(x);
Wire.endTransmission();
digitalWrite(led, LOW);
Serial.print("x is ");
Serial.println(x);
x++;
delay(500);
}
Slave Script
Code:
#include <Wire.h>
int led = LED_BUILTIN;
void setup()
{
pinMode(led, OUTPUT);
Wire.begin(0x10);
Wire.onReceive(receiveEvent);
Serial.begin(9600);
}
void loop()
{
Serial.println("Waiting...");
delay(1500);
}
void receiveEvent(int howMany)
{
digitalWrite(led, HIGH);
while(Wire.available() > 1) {
char c = Wire.read();
Serial.print(c);
}
int x = Wire.read();
Serial.println(x);
digitalWrite(led, LOW);
}
Any help or thoughts are greatly appreciated