Hardware Reference
In-Depth Information
Once you know
the RFID reader
works, it's time to test the X10 output.
This sketch turns on Unit 1 in house
A for half a second, then turns it off.
To test it, plug in your X10 interface
module to the wall, and plug in a lamp
module with a lamp connected and
turned on to the same circuit in your
house. When the sketch runs, the lamp
should blink.
Test the X10
/*
X10 blink
Context: Arduino
*/
#include <x10.h>
const int rxPin = 3; // data receive pin
const int txPin = 4; // data transmit pin
const int zcPin = 2; // zero crossing pin
void setup() {
// initialize serial and X10:
Serial.begin(9600);
x10.begin(rxPin, txPin, zcPin);
}
void loop() {
// open transmission to house code A:
x10.beginTransmission(A);
Serial.println("Lights on:");
// send a "lights on" command:
x10.write(ON);
delay(500);
Serial.println("Lights off:");
// send a "lights off" command:
x10.write(OFF);
x10.endTransmission();
delay(500);
}
It's unlikely that this will work the first time.
X10 is notorious for having synchronization
problems while you're developing the hardware
and firmware. For one thing, it doesn't work when the
transmitter and receiver are on different circuits, so
you need to know which circuits in your house's circuit-
breaker panel control which outlets. Some surge pro-
tectors and power strips might filter out X10 as well, so
make sure that the X10 units are plugged into the wall,
not the surge protector. You can plug surge protectors
into X10 appliance modules, but avoid plugging them into
lamp modules unless everything plugged into the surge
protector is an incandescent lamp.
fluorescent bulbs are generally not dimmable, and they
are not designed for use on lamp modules either. If
you're unsure, use an appliance module instead of a lamp
module.
If your lights don't turn on correctly, first unplug every-
thing, then set the addresses, then plug everything back in,
then reset the Arduino. If that fails, make sure your units
are on the same circuit, and eliminate surge protectors (if
you're using them.) Try to turn the modules using a control
panel module. Make sure the control panel isn't sending an
ALL UNITS OFF signal at the same time as your Arduino. If
needed, unplug the control panel once you know the lamp
module is responding. Once you've got control over your
modules, you can combine the RFID and X10 programs.
X
X10 lamp modules allow you to dim incandescent lights,
but they will control only resistive loads—that means no
blow dryers, blenders, or anything with a motor. Compact
 
Search WWH ::




Custom Search