Hardware Reference
In-Depth Information
N You might have heard that there is a temperature sensor built in to the Arduino—this is partially true! It was
included in the 328 series (chips with an '8P' part number) and its clones (ATmega16P and ATmega168PA) but, alas,
no others. If you're lucky enough to have this version, then you can find suitable code at
https://code.google.com/p/tinkerit/wiki/SecretThermometer .
Note
The method of reading analog inputs doesn't change if you use a different type of sensor. Indeed, there's a QM-NG1 gas
sensor that could be replaced into the above circuit to give an audible warning if a leak is detected in the kitchen. Similarly,
the MQ2 smoke detector could be used for a similar purpose. Both cases are traditionally confined to local warnings.
But by passing the warning to your phone through a SMS alert (see Chapter 5 for details on how to send such messages)
you can call a friend or neighbor to check for you, particularly as the alarms might not be audible outside the dwelling.
Sending Digital Outputs
This is as simple as it sounds and includes those cases in which you want to send nothing more than a simple on/off
to something like a light switch or small motor. The code requires a simple setup and invocation like this:
int outputLightPin = 2;
pinMode(outputLightPin, OUTPUT);
//
digitalWrite(outputLightPin, bState ? TRUE : FALSE);
From here, it's all about the circuit.
Each pin on the Arduino is able to source current, up to around 40 milliamps. This is enough for most small loads
such as lights, buffers, and some small motors. If your device uses no more than 300 milliamps, then you can draw this
from the circuit board itself using the Arduino as a switch only with a circuit like that in Figure 2-5 .
+ve
Load
Output Pin 2
Figure 2-5. A transistor switch circuit, allowing you to draw up to 300mA
For anything larger, you will need to employ a relay and separate power source, as shown in Figure 2-6 .
 
Search WWH ::




Custom Search