StackBook Part 2 - the system bus
13 08 09 - 18:16 Firstly we need to get the chips communicating. This is done by I2C (aka TWI).Tips: It's always on the same pins (SDA and SCL). Remember the pull-up resistors.
Test Program:
On the CPU:
#include <Wire.h>
void setup()
{
Wire.begin();
pinMode(1, INPUT);
}
void loop()
{
Wire.beginTransmission(4);
Wire.send(digitalRead(1));
Wire.endTransmission();
delay(100);
}
On the auxillary controller:
#include <Wire.h>
int ledPin = 1;
void setup()
{
pinMode(ledPin, OUTPUT);
Wire.begin(0x04);
Wire.onReceive(receiveEvent);
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
}
void loop()
{
delay(100);
}
void receiveEvent(int howMany) {
char c = Wire.receive();
if (c == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
And here's two pictures of two ICs doing the job of none.

Trackback link: http://gm.stackunderflow.com/blog/pivot/tb.php?tb_id=125