Hardware Reference
In-Depth Information
Stepping outside of 802.11, the main alternative is the Xbee shield, which uses the ZigBee wireless protocol,
meaning it is not directly compatible with existing WiFi connections but can act as a radio transmitter and receiver
for basic scenarios and has an improved indoor range of about 30 meters. This is often a better choice for connecting
sheds and outhouses to the house, for basic security measures.
Motors
The motor shield, from LadyAda, supports medium power control for DC, servo, and stepper motors. The total number
of supported motors and the total power drain are governed by the specific motors themselves, but the quoted specs
permit you two DC servos (on 5V) and up to four DC motors, two stepper motors, or one stepper and up to two DC
motors. This shield does utilize a lot pins for control, and a lot of power, but can be used to lock cat flaps or build a robot.
Example: The Arduino Welcome Mat
With this knowledge, you can build a simple circuit, write some Arduino software, and add a Linux-side script to
trigger a piece of speech whenever someone enters or leaves the house.
I'll show how to use the Arduino to monitor the state of a pressure mat (using a normally open switch) placed
under a rug and transmit messages to the PC. The Arduino will also remember the current state, so once the switch
inside the pressure mat has been stepped on, the house state is assumed to be “vacant” since people have left the
house, and when the switch is closed again, the state changes to “occupied.” The circuit is a simple switch, as shown in
Figure 2-2 . Naturally, you could write the same code on a Raspberry Pi, but there is no reason to waste so many CPU
cycles unless you were also going to add a front door cam or other such feature.
N You can also use a pressure mat to determine whether you've gotten out of bed after your alarm has gone off,
and you can use the act of leaving the bedroom as a means to stop the alarm from sounding.
Note
The Arduino software is slightly more complex because you are looking for the case when the switch goes from
the closed state to the open, as people might stand on the mat for a minute or more while they put on their coat. I have
also included a timer here so that the house state doesn't change if a second rising edge (caused by someone else
stepping on the mat) is detected within two seconds of the first. This is to allow several people to leave the house at
once, without the state getting confused. Naturally, this doesn't solve the problem of only some occupants leaving the
house, but it's a start!
int inputSwitchPin = 2;
int lastState;
long timeLastPressed;
long debouncePeriod = 100;
int houseState;
long doormatUnblockAt;
long doormatDelayPeriod = 2000;
int blockSteps;
void setup() {
Serial.begin(9600);
pinMode(inputSwitchPin, INPUT); // declare pushbutton as input
lastState = digitalRead(inputSwitchPin);
 
Search WWH ::




Custom Search