JupiterMoll
Member
Hallo,
I'm triyng to send Data over IC2
from a Teensy 4.1 (Master) >>> to >>> Teensy 4.1 (Slave)
Both Teensys are grounded together and use SCL Pin : 19 and SDA Pin : 18.
The Wires are short.
For testing I' using this code examples from the Wire Library.
Master- Sender- Teensy 4.1
Slave - Reciver - Teensy 4.1
Sadly I got no output on the Reciver ?
Any ideas?
Thx.
I'm triyng to send Data over IC2
from a Teensy 4.1 (Master) >>> to >>> Teensy 4.1 (Slave)
Both Teensys are grounded together and use SCL Pin : 19 and SDA Pin : 18.
The Wires are short.
For testing I' using this code examples from the Wire Library.
Master- Sender- Teensy 4.1
Code:
#include <Wire.h>
int led = 24;
void setup()
{
pinMode(led, OUTPUT);
Wire.begin(); // join i2c bus (address optional for master)
}
byte x = 0;
void loop()
{
digitalWrite(led, HIGH); // briefly flash the LED
Wire.beginTransmission(9); // transmit to device #9
Wire.write("x is "); // sends five bytes
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting
digitalWrite(led, LOW);
x++;
delay(500);
}
Slave - Reciver - Teensy 4.1
Code:
#include <Wire.h>
int led = LED_BUILTIN;
void receiveEvent(int howMany);
void setup()
{
pinMode(led, OUTPUT);
Wire.begin(9); // join i2c bus with address #9
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
while(!Serial)
{
}
Serial.println("RECIVER IC2");
}
void loop()
{
delay(100);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
digitalWrite(led, HIGH); // briefly flash the LED
while(Wire.available() > 1) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
digitalWrite(led, LOW);
}
Sadly I got no output on the Reciver ?
Any ideas?
Thx.