well i got it all figured out but what do you mean its not a receipt for a reliable system
for master i have
#include <Wire.h>
#define LIGHTS_PIN 2 // Pin 2 on local
#define FANS_PIN 3 // Pin 3 on local
#define HORNS_PIN 4 // Pin 4 on local
#define WIPERS_PIN 5 // Pin 5 on local
#define WASHERS_PIN 6 // Pin 6 on local
#define FOGS_PIN 7 // Pin 7 on local
#define BRAKELIGHTS_PIN 8 // Pin 8 on local
#define LEFTBLKS_PIN 9 // Pin 9 on local
#define RIGHTBLKS_PIN 10 // Pin 10 on local
#define HAZARDS_PIN 11 // Pin 11 on local
#define HEADLIGHT_PIN 102 // Pin 2 on remote
#define FAN_PIN 103 // Pin 3 on remote
#define HORN_PIN 104 // Pin 4 on remote
#define WIPER_PIN 105 // Pin 5 on remote
#define WASHER_PIN 106 // Pin 6 on remote
#define FOG_PIN 107 // Pin 7 on remote
#define RIGHTBLK_PIN 108 // Pin 8 on remote
#define TAILIGHT_PIN 112 // Pin 2 on remote
#define BRAKELIGHT_PIN 113 // Pin 3 on remote
#define LICENESLAMP_PIN 114 // Pin 4 on remote
#define RRIGHTBLK_PIN 115 // Pin 5 on remote
#define RLEFTBLK_PIN 116 // Pin 6 on remote
int light = 0; // variable for reading the pushbutton status
int fan = 0;
int horn = 0;
int wiper = 0;
int washer = 0;
int fog = 0;
int brakelight = 0;
int rightblk = 0;
int leftblk = 0;
int hazard= 0;
void setup()
{
Wire.begin(); // join i2c bus
}
void loop()
{
light = digitalRead(LIGHTS_PIN);
if (light == HIGH) {
frontWrite(HEADLIGHT_PIN,HIGH);
backWrite(TAILIGHT_PIN,HIGH);
backWrite(LICENESLAMP_PIN,HIGH);
}
else {
frontWrite(HEADLIGHT_PIN,LOW);
backWrite(TAILIGHT_PIN,LOW);
backWrite(LICENESLAMP_PIN,LOW);
}
hazard = digitalRead(HAZARDS_PIN);
if (hazard == HIGH) {
frontWrite(RIGHTBLK_PIN ,HIGH);
frontWrite(LEFTBLK_PIN ,HIGH);
backWrite(RLEFTBLK_PIN,HIGH);
backWrite(RRIGHTBLK_PIN,HIGH);
}
else {
frontWrite(RIGHTBLK_PIN,LOW);
frontWrite(LEFTBLK_PIN ,HIGH);
backWrite(RLEFTBLK_PIN,HIGH);
backWrite(RRIGHTBLK_PIN,LOW);
}
rightblk = digitalRead(RIGHTBLKS_PIN);
if (rightblk == HIGH) {
frontWrite(RIGHTBLK_PIN ,HIGH);
backWrite(RRIGHTBLK_PIN,HIGH);
}
else {
frontWrite(RIGHTBLK_PIN,LOW);
backWrite(RRIGHTBLK_PIN,LOW);
}
leftblk = digitalRead(LEFTBLKS_PIN);
if (leftblk == HIGH) {
frontWrite(LEFTBLK_PIN ,HIGH);
backWrite(RLEFTBLK_PIN,HIGH);
}
else {
frontWrite(LEFTBLK_PIN,LOW);
backWrite(RLEFTBLK_PIN,LOW);
}
fan = digitalRead(FANS_PIN);
if ( fan == HIGH) {
frontWrite(FAN_PIN,HIGH);
}
else {
frontWrite(FAN_PIN,LOW);
}
horn = digitalRead(HORNS_PIN);
if ( horn == HIGH) {
frontWrite(HORN_PIN,HIGH);
}
else {
frontWrite(HORN_PIN,LOW);
}
wiper = digitalRead(WIPERS_PIN);
if ( wiper == HIGH) {
frontWrite(WIPER_PIN,HIGH);
}
else {
frontWrite(WIPER_PIN,LOW);
}
washer = digitalRead(WASHERS_PIN);
if ( washer == HIGH) {
frontWrite(WASHER_PIN,HIGH);
}
else {
frontWrite(WASHER_PIN,LOW);
}
fog = digitalRead(FOGS_PIN);
if ( fog == HIGH) {
frontWrite(FOG_PIN,HIGH);
}
else {
frontWrite(FOG_PIN,LOW);
}
brakelight = digitalRead(BRAKELIGHTS_PIN);
if ( brakelight == HIGH) {
backWrite(BRAKELIGHT_PIN,HIGH);
}
else {
backWrite(BRAKELIGHT_PIN,LOW);
}
}
void frontWrite(int pin, int value)
{
pin = pin-100; // substracts 100 so it maps to the real ports on the expansion arduino
Wire.beginTransmission(1); // transmit to device #1
Wire.write(pin); // sends one byte stating the pin to be addressed
Wire.write(value); // sends the value to be transmitted to the pin selected
Wire.endTransmission(); // stop transmitting
}
void backWrite(int pin, int value)
{
pin = pin-110; // substracts 100 so it maps to the real ports on the expansion arduino
Wire.beginTransmission(2); // transmit to device #2
Wire.write(pin); // sends one byte stating the pin to be addressed
Wire.write(value); // sends the value to be transmitted to the pin selected
Wire.endTransmission(); // stop transmitting
}
and for the front slave
#include <Wire.h>
void setup()
{
Wire.begin(1); // join i2c bus with address #1
Wire.onReceive(receiveEvent); // register event
}
void loop()
{
// Whatever. maybe nothing.
}
void receiveEvent(int howMany)
{
int port = Wire.read(); // receive byte as an integer
int value = Wire.read(); // receives the byte with the value
digitalWrite(port,value); // sets the pin to the desired value
}
its the same for the second but i changed the address
so what would be a more reliable way of doing this