
IDENTIFICATION 321
Continued from opposite page.
if (tagIndex < tagLength) {
tagID[tagIndex] = thisChar;
// increment the tag byte counter
tagIndex++;
}
break;
}
}
/*
X10 test
language: Wiring/Arduino
*/
// include the X10 library files:
#include <x10.h>
#include <x10constants.h>
#define zcPin 9 // the zero crossing detect pin
#define dataPin 8 // the X10 data out pin
#define repeatTimes 1 // how many times to repeat each X10 message
// in an electrically noisy environment, you
// can set this higher.
// set up a new x10 library instance:
x10 myHouse = x10(zcPin, dataPin);
void setup() {
// turn off all lights:
myHouse.write(A, ALL_UNITS_OFF,repeatTimes);
}
void loop() {
// turn on first module:
myHouse.write(A, UNIT_1,repeatTimes);
myHouse.write(A, ON,repeatTimes);
myHouse.write(A, UNIT_2,repeatTimes);
myHouse.write(A, OFF,repeatTimes);
delay(500);
// turn on second module:
myHouse.write(A, UNIT_1,repeatTimes);
myHouse.write(A, OFF,repeatTimes);
myHouse.write(A, UNIT_2,repeatTimes);
myHouse.write(A, ON,repeatTimes);
delay(500);
}
When you know that works, run
this sketch to test the X10:
8
Making_Things_Talk.indb 321 11/13/09 4:57 PM