********************SOLVED(I think ) **************************
ok - this is working for both uno to uno transmission, and uno to I2C LCD at the same time. I am not using the interrupt method, but rather a "send data as needed" call, since the data is just for user display, doesn't need to be 100% realtime. also using the I2C SendAnything library - works nicely. I had problems with my LCD working OK, then showing garbage - I had to add a delay (or sampling rate really) for the LCD not to get boned.
The wiring for this test - if you freak out on pin 16/17 - go find a uno r3 pinout
UNO "A" -or my sender.
vcc/gnd to proto board
pin 16 to Uno B Pin 16
pin 17 to Uno B pin 17
Uno "B" - or my receiver
vcc/gnd to proto board
A5 to SCL input on LCD
A4 to SDA input on LCD
pin 16 to Uno A pin 16
Pin 17 to Uno A pin 17
LCD -
vcc/gnd proto board
SLC to Uno B pin 5
SDA to Uno B pin 4
The Sender (my core unit doing the "i/o work" in my project)
#include <Wire.h>
#include <I2C_Anything.h>
unsigned int x=0;
void setup()
{
Wire.begin(0);
}
void loop()
{
x++;
delay(1000);
MyTX();
}
void MyTX()
{
Wire.beginTransmission (13);
I2C_writeAnything(x);
Wire.endTransmission ();
}
My receiver - basic setup only, no LCD for early test
#include <Wire.h>
#include <I2C_Anything.h>
int x=0;
void setup()
{
Serial.begin(9600);
Wire.begin(13);
Wire.onReceive(receiveEvent);
}
void loop()
{
Serial.print("loop");
Serial.print("\t");
Serial.print(x);
Serial.print("\n");
}
void receiveEvent(int byteCount)
{
I2C_readAnything(x);
}
receiver with LCD too - just replace first test receiver code, sender code remains the same
#include <Wire.h>
#include <I2C_Anything.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x3F // <<----- Add your address here. Find it from I2C Scanner
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
unsigned int x=0;
unsigned int lastX = 0;
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
void setup()
{
Serial.begin(9600);
Wire.begin(13);
Wire.onReceive(receiveEvent);
lcd.begin (16,2); // <<----- My LCD was 16x2
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home
lcd.clear();
}
void loop()
{
lastX=x;
Serial.print("loop");
Serial.print("\t");
Serial.print(x);
Serial.print("\n");
if(x !=lastX)
{
MyLCD();
}
}
void MyLCD()
{
lcd.setCursor (0,0);
lcd.print("SurferTim Rocks");
lcd.setCursor (0,1);
lcd.print(x);
lcd.print(" ");
}
void receiveEvent(int byteCount)
{
I2C_readAnything(x);
}