Hardware Reference
In-Depth Information
+ve
Normally open
Powered
Device
Common
Relay
Coil
Normally closed
Output Pin 2
Figure 2-6. Using a relay to control high power loads
N In reality, the Arduino is good for higher power loads up to 800 mA. But for dirty loads, such as motors,
the 300 mA is probably more conservatively sensible.
Note
Sending Analog Outputs
As mentioned previously, analog output is available on the basic Arduino only when using PWM. This is supported
only on pins 3, 5, 6, 9, 10, 11, and 21. 9 The pulsing of the output pin to provide the output is handled automatically,
including the setup, so you need only to write this:
analogWrite(analogWritePin, value); // value is between 0 and 255, inclusive
This will allow you to vary the brightness of LEDs and the volume of piezo-buzzers and speakers, but not a lot
else. In reality, you won't need a lot else in home automation environs. Moving a motor to a specific position, for
example, is better done with servo or stepper motors, and many other forms of positioning should be done through
the use of feedback loops—switching the motor on to begin movement and switching it off when a sensor reveals it
has gone far enough.
Creating Audio Outputs
This is one of the simplest forms of human-friendly feedback the Arduino can provide, because the circuit needs only
a buzzer attached to a digital output pin. The code is a simple loop changing the output state between on and off 440
times a second, for example, to produce the A note above middle C.
The examples on the main Arduino site provide the necessary code to make it beep and play short tunes. For those
looking for more advanced music control, there is Armstrong ( www.bluedust.dontexist.com/armstrong ), the Arduino
music system, which provides a small melody processor allowing you to play the chimes of Big Ben with code like this:
ancInitialize(OUTPUT_LOCAL);
ancAssignChannelToPin(CHANNEL_OUTPUT_PIEZO_SPEAKER, piezoPin);
char *pChimesPhrase1 = "L32O4edcL64O3g";
char *pChimesPhrase2 = "L32O4cedL64O3g";
/LDERBOARDSUSINGTHE!4MEGASUPPORTONLYPINSANDWHEREASTHENEWER!RDUINO-EGACANSUPPORT07-ONOFITSPINS
 
Search WWH ::




Custom Search