Hi,
I’m very new to this but I’m trying my luck with a teensy 3.6.
What I’m trying to do is just to have the teensy register when i send it an i2c message on pin18 and 19.
But it seems like it either isn’t reacting or maybe not even receiving anything.
I’m trying to send it messages from my teletype, with a powered busboard, so that should take care of the pullup resistors, right?
Here you can see my simple code, which compiles fine, and runs and blinks the LED.
#include <i2c_t3.h>
int howManyReceived;
void setup() {
pinMode(LED_BUILTIN,OUTPUT); // LED
//init variable
howManyReceived = 0;
// Setup for Slave mode, address 0x20, pins 18/19, external pullups, 400kHz
Wire.begin(I2C_SLAVE, 0x20, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
Wire.onReceive(receiveEvent);
Serial.begin(115200);
}
void loop() {
// blinking LED to make sure it's alive
digitalWrite(LED_BUILTIN,HIGH);
delay(10);
digitalWrite(LED_BUILTIN,LOW);
delay(400);
//print how many things happened
Serial.println(howManyReceived);
}
void receiveEvent() {
// increment howManyReceived
howManyReceived = howManyReceived + 1;
}
The main idea is just to send it a i2c message on the whitewhale adress, and then print the number of messages i’ve sent in the serial monitor.
I’m sending it the white whale position message.
WW.POS 1
Is there something i’m simplifying in my code, or shouldn’t this theoretically work?
I connect SCL to pin 19 and SDA to pin 20, and GND to GND on the teensy.
Any help, pointing in the direction of a resource that can teach me is greatly appreciated.
Thanks
Anders