0% found this document useful (0 votes)
127 views33 pages

Arduino-Info - ArduinoPower PDF

Uploaded by

Nc Bean
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
127 views33 pages

Arduino-Info - ArduinoPower PDF

Uploaded by

Nc Bean
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 33

4/14/2018 arduino-info - ArduinoPower

You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

ArduinoPower (/ArduinoPower)
 Edit  0 (/ArduinoPower#discussion)  164 (/page/history/ArduinoPower)

… (/page/menu/ArduinoPower)

Arduino Power !

(Power Switching devices for Arduino)


Left-Right: A "relay electronic brick", a 4-relay
board, an 8-relay optically-isolated board, a 4-
Power-FET "brick"

Powering Arduino Itself: (Different Subject!)

Controlling Power With Arduino


Having your Arduino control higher-power devices like
lights, motors, pumps, doors, and many more is one of
the most interesting and useful applications you may get
involved with. But it can be a little difficult and possibly
dangerous when power line voltages are being
controlled. There are significant differences in
controlling AC power compared to DC. And there are
considerations about different kinds of loads and so

https://arduino-info.wikispaces.com/ArduinoPower 1/33
4/14/2018 arduino-info - ArduinoPower

forth. This section will cover many of these subjects,


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

show several available devices you can connect to


Arduino to control power (examples above), and provide
examples of working projects. (Please direct questions,
critiques and suggestions to: terry@yourduino.com )
NOTE: Sometimes switching lights, motors, etc. with
relays can cause Electromagnetic Interference (EMI).
More information about what to do in these cases is
available HERE:
NOTE: Here's more information on selecting relays and
understanding relay contacts.

Please read This Electrical Safety and Disclaimer page


before using any of these devices.

Outline:
Arduino By Itself: Pin Current Limitations (Link
to page)
Arduino Controlling Higher Power: A simple
example
2-relay, 4-relay and 8-relay boards
"Optical Isolation"
AC vs DC: Why do I care?
DC Switching
Power Control: Dimming / Speed
120-240 VOLTS Solid State Relays - AC Power
Control: ON-OFF
POWER: How much?

https://arduino-info.wikispaces.com/ArduinoPower 2/33
4/14/2018 arduino-info - ArduinoPower

Power sources and Loads


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

Power Control Circuits


Power switching devices
Some example projects and directions

A simple example:
Get your Arduino plugged into your main computer, and
download the Good Old Blink Program. If you need help
getting started, go here... You should have the LED on
your Arduino blinking ON for 1 second, OFF for 1
second.

Now, what if you want to have a large light blink on and


off like that?? First, let's look at ways of physically
plugging things into Arduino.

Pins, Bits and All That:


You should be getting familiar with Arduino and it's pin
connections. So what's this stuff all about??

PINS
BITS
ONES and ZEROS
HIGH and LOW...
If you're pretty familiar with those words and ideas,
fine. But if you'd like to learn a little more before we

https://arduino-info.wikispaces.com/ArduinoPower 3/33
4/14/2018 arduino-info - ArduinoPower

continue, jump over here and then come back...


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

Arduino Connection Options:

There are a few different ways of connecting devices


to Arduino's I/O and Analog pins:
Plug small wires or pins on the ends of wires into
the black holes of the Arduino connectors and
run them directly to the devices.
Plug small wires or pins on the ends of wires into
the Arduino and then into a "Solderless
Breadboard" where other devices can be plugged
in and connections made. (Example)
Plug a circuit board (usually called a "Shield") on
top of Arduino, plugging into most or all Arduino
pins. These Shields are usually special-purpose
add-ons to Arduino to do things like control robot
motors, connect to the Internet, etc.(Examples) .
Use an Arduino-compatible board like the
YourDuinoRobo1 which has many added
connectors to make plugging devices easy.

https://arduino-info.wikispaces.com/ArduinoPower 4/33
4/14/2018 arduino-info - ArduinoPower

Plug a special "Sensor Shield" (Example) on top of


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

Arduino that gives you the 3-pin connectors like a


YourDuinoRobo1. IF you have a larger board like
an Arduino or YourDuino MEGA, you'll need a
MEGA sensor shield to make the many pins
easily useable. . Then you can easily plug cables
and other devices into all the Arduino I/O,
Analog and Communications ports. You can also
plug in cables from many different devices in the
form of "Electronic Bricks" (Example), to quickly
try out different options and test and develop
software. We'll use this in our next examples.
NOTE: We have a Page on cables and connections HERE:

Example- Blink a table lamp:


OK, if you have the Blink program running, a small LED is
blinking on your Arduino. Here, we have plugged a
Sensor Shield on top of the Arduino, and plugged in a
small Electronic Brick with a short cable.

Now there is a small LED ("L" on the red relay brick)


blinking on and off the same as the LED on Arduino. And
if you listen you can hear the relay clicking on and off
too. A Relay is a switch that is operated by an
electromagnet. (More about relays) . In this example,
our Arduino has the very easy job of driving a 10,000
ohm resistance with Digital I/O Pin 13.

https://arduino-info.wikispaces.com/ArduinoPower 5/33
4/14/2018 arduino-info - ArduinoPower

The
You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

Electronic Brick system is an easy way to connect


dozens of different devices to Arduino and try them
out or make working systems. But you can make many of
these circuits yourself if you want, and they are good
examples. Let's look in more detail at the Relay Brick:

The Relay Brick uses some simple electronics principles


that you can apply to other Output Devices for Arduino.
Here's the fundamental principle:

https://arduino-info.wikispaces.com/ArduinoPower 6/33
4/14/2018 arduino-info - ArduinoPower

You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

"Electronic Devices using small amount of power, can


Control a much larger amount of power"

The Relay Brick does this in two steps. Let's look at a


diagram of what's on that little Brick:

First, notice the cable connector has a standard


pattern of wires: Ground-Voltage-Signal (see the GVS
labels on the Sensor Shield above). So the brick has +5
volt power available. Here's what happens:
When the Blink Software Sketch does "
digitalWrite(13, HIGH); " the Arduino connects
the Signal wire to HIGH, which is +5 Volts.
+5 volts flow through 10,000 ohm resistor R1 to
the Base of transistor Q1, and a current of about
.0005 amps (500 microamps) flows and turns the
transistor ON.

https://arduino-info.wikispaces.com/ArduinoPower 7/33
4/14/2018 arduino-info - ArduinoPower

The transistor connects one end of the


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

electromagnet inside the relay to Ground (the


other end is already connected to 5 volts), and a
current of about .07 amps flows. We say the
transistor has a Current Gain of more than 100.
The electromagnet pulls the switch contact inside
and moves it to connect the COM terminal to the
NO (Normally Open) terminal.
A Lamp, or other load, is connected by the relay
contacts. Let's say it might be a 100 watt lamp.
Details: the diode across the electromagnet
conducts in the reverse direction when the
transistor is turned off to protect against a
voltage spike.
Details: An LED and it's current limiting resistor
are also connected across the electromagnet and
it lights up when the relay is turned on. Just for
you...

This is the way high power can be controlled by a very


small power from Arduino. Let's quickly think about the
numbers:

Arduino outputs 5 Volts at .0005 amps. Multiply


and that's .0025 watts (2.5 milliwatts) Not Much!
The transistor controls 5 Volts at .07 amps.
That's, um, .35 watts.

https://arduino-info.wikispaces.com/ArduinoPower 8/33
4/14/2018 arduino-info - ArduinoPower

The relay controls, say, 220 Volts at .5 amps.


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

That's 110 watts.

So with this little brick, Arduino controls a power 4400


times it's own power. That's what this power control
stuff is all about.

How Relay Contacts Work:


Look at the photo of a relay down below on the right.
Notice the 3 screw-type terminals. They are labelled
"NO", "COM", "NC". Those labels mean:

NO: Normally Open


COM: Common Connection
NC: Normally Closed
Look at the diagram on the right. This shows the switch
that is inside the relay. This switch is "thrown" by the
electromagnet inside. The diagram shows that COM is
connected to the Normally Closed contact. That's the

https://arduino-info.wikispaces.com/ArduinoPower 9/33
4/14/2018 arduino-info - ArduinoPower

case when the relay is off. When the relay is turned on


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

the electromagnet flips the switch up and COM is then


connected to Normally Open. So, if we want a lamp to
be on when the relay is on, we connect our circuit from
COM to NO. Let's try that out.

More About Relays HERE:


Good detailed RELAY Information and Tutorial
here:

Using two typical SPDT (Single Pole Double Throw)


relays to control a DC motor:
DC Motors can be controlled to Run in either direction
or stop, with two relays. See the diagram at the right.
When both relays are off, both motor terminals are
connected to the same point and the motor is stopped.

https://arduino-info.wikispaces.com/ArduinoPower 10/33
4/14/2018 arduino-info - ArduinoPower

If one relay is activated, one motor terminal is


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

connected to the opposite polarity and it runs in that


direction. If the other relay is activated, the motor
connected in the opposite polarity. (If Both relays were
activated the motor would also stop!).

NEXT: Blinking a Lamp on and off:


OK, we have the relay clicking on and off. Inside, the
COM terminal is connected to the NO (Normally Open)
terminal when the relay is on. So all we have to do is use
that switch to turn the lamp on and off.

We're going to use a low-voltage lamp from IKEA, to


make things a little safer. IF you wire this type

relay
to
switch
"Mains

https://arduino-info.wikispaces.com/ArduinoPower 11/33
4/14/2018 arduino-info - ArduinoPower

Voltage" (115V in USA and others, 220V in Europe and


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

others) you MUST take precautions. READ THIS


DISCLAIMER!

We will simply cut one side of the cable to the lamp, and
route that connection through the relay from COM to
NO.

Here's the way that looks:

And if we draw that as a schematic diagram it would be


something like this:{TBD}

Here's
the
relay

connected to Arduino, and the light turning ON:

You can use any of the Arduino I/O pins to drive a

https://arduino-info.wikispaces.com/ArduinoPower 12/33
4/14/2018 arduino-info - ArduinoPower

relay, because you will simply turn it ON or OFF.


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

More Complex Systems:

If you do something a little bit more complex, like


controlling an aquarium, a plant growing system, or a
home energy management system, you'll need more
relays. Let's look more closely at the 4-relay and 8-
relay boards shown in the top of page photo. (You can
get them here). And you can see their schematic
diagrams on the product pages. You can build these
circuits yourself if you wish, or prototype things like
the examples here.

IMPORTANT NOTE: There is a issue with start-up of


Arduino programs that control these relays. All of
these 2,4, or 8 relay boards input controls are Active
LOW, meaning that setting a pin LOW turns them ON.
To assure that no relays activate at Reset or Power-On
until you want them to, the initialization sequence in
SETUP should be:
1. digitalWrite(Relay, HIGH);
2. pinMode(Relay, OUTPUT);

This design is intentional, so that it is possible to


guarantee that at power-on of a system, or system
reset, that no relays activate except when expected
under program control. There may be pumps, lights etc

https://arduino-info.wikispaces.com/ArduinoPower 13/33
4/14/2018 arduino-info - ArduinoPower

attached and chaos could ensue if this was not


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

controlled definitively for each output port being used.

Then in the main Loop section turn relays On or Off as


needed... Following is an example program that properly
controls 4 relays on our 4-relay board (Available HERE
)

/* YourDuino Example: Relay Control 1.10


Handles "Relay is active-low" to assure
no relay activation from reset until
application is ready.
terry@yourduino.com */

/*-----( Import needed libraries )-----*/


/*-----( Declare Constants )-----*/
#define RELAY_ON 0
#define RELAY_OFF 1
/*-----( Declare objects )-----*/
/*-----( Declare Variables )-----*/
#define Relay_1 2 // Arduino Digital I/O pin number
#define Relay_2 3
#define Relay_3 4
#define Relay_4 5

void setup() /****** SETUP: RUNS ONCE ******/


{
//-------( Initialize Pins so relays are inactive at reset)----
digitalWrite(Relay_1, RELAY_OFF);
digitalWrite(Relay_2, RELAY_OFF);
digitalWrite(Relay_3, RELAY_OFF);
digitalWrite(Relay_4, RELAY_OFF);

//---( THEN set pins as outputs )----


pinMode(Relay_1, OUTPUT);
pinMode(Relay_2, OUTPUT);
pinMode(Relay_3, OUTPUT);
pinMode(Relay_4, OUTPUT);
delay(4000); //Check that all relays are inactive at Reset

}//--(end setup )---

https://arduino-info.wikispaces.com/ArduinoPower 14/33
4/14/2018 arduino-info - ArduinoPower

You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

void loop() /****** LOOP: RUNS CONSTANTLY ******/


{
//---( Turn all 4 relays ON in sequence)---
digitalWrite(Relay_1, RELAY_ON);// set the Relay ON
delay(1000); // wait for a second
digitalWrite(Relay_2, RELAY_ON);// set the Relay ON
delay(1000); // wait for a second
digitalWrite(Relay_3, RELAY_ON);// set the Relay ON
delay(1000); // wait for a second
digitalWrite(Relay_4, RELAY_ON);// set the Relay ON
delay(4000); // wait see all relays ON

//---( Turn all 4 relays OFF in sequence)---


digitalWrite(Relay_1, RELAY_OFF);// set the Relay OFF
delay(1000); // wait for a second
digitalWrite(Relay_2, RELAY_OFF);// set the Relay OFF
delay(1000); // wait for a second
digitalWrite(Relay_3, RELAY_OFF);// set the Relay OFF
delay(1000); // wait for a second
digitalWrite(Relay_4, RELAY_OFF);// set the Relay OFF
delay(4000); // wait see all relays OFF

}//--(end main loop )---

//*********( THE END )***********

Below is a 4-relay board and a photo of it being run by


the example software Sketch above.

NOTE: This a family of boards with 1,2,4,or 8 relays).


(SEE Them HERE) )

https://arduino-info.wikispaces.com/ArduinoPower 15/33
4/14/2018 arduino-info - ArduinoPower

You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

NOTE: The relays used are made by SONGLE and the


specification sheet is here:
SRD-05VDC-SL-C-Datasheet.pdf
Details Download 100 KB

The 30A version SONGLE relay is shown here:


SLA-05VDC-SL-C_Datasheet.pdf
Details Download 72 KB

There are both Optically-isolated versions


(recommended for most applications) and non-isolated
versions. It has the same relay as the Electronic Brick
1-relay board and basically the same transistor drive
circuitry. You would connect Arduino to the connector
on the upper left. +5V to VCC, four input pins, and GND.

NOTE: A difference is that these control pins are


Active LOW which means the relay turns on when you
set the Arduino output to LOW.

You can wire the relay outputs to various devices rated


at up to 10 Amps. The connections on the far right have
a diagram similar to that shown above.

There are LEDs on the board that show when a relay is


active, and a green LED to show that +5V power is
applied. Notice how our multicolor flat cable and
Sensor Shield makes this easy to connect! And the

https://arduino-info.wikispaces.com/ArduinoPower 16/33
4/14/2018 arduino-info - ArduinoPower

YourDuinoRobo1 microcomputer board has those


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

connectors built in.

https://arduino-info.wikispaces.com/ArduinoPower 17/33
4/14/2018 arduino-info - ArduinoPower

You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

Here is a different 8-relay board. (Available HERE) It


has an added feature of Optical Isolation. This means

https://arduino-info.wikispaces.com/ArduinoPower 18/33
4/14/2018 arduino-info - ArduinoPower

You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

that all Arduino really does is turn on an LED inside an


IC package, and THAT turns the relay on. So there does
not need to be any direct connection between Arduino
and the relay driver circuits. This can be an advantage
and safety factor when controlling a separate piece of
equipment that has it's own power supplies and perhaps
a metal case etc. (2 and 4 Relay Boards are also
available).

The 8-relay board shown here gives you a choice of


powering the relay drive circuits from the same supply
as Arduino, or isolating Arduino by removing the jumper
over at the right. In that case you need to have some
separate +5V supply connected to GND and the "JD-
VCC" pin (whatever THAT label means...). Here's a

https://arduino-info.wikispaces.com/ArduinoPower 19/33
4/14/2018 arduino-info - ArduinoPower

closeup look at the pins:


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

If you isolate Arduino, you need to connect +5V ONLY


(NOT GND) from Arduino to the VCC pin. The Arduino
output pins go to IN1 through IN8. And again, these
pins are Active LOW. NOTE: Some relay boards have 2
GND pins; they are connected together.

The separate 5V supply would go from


JD-VCC (Jumper removed)
GND
The ONLY connection to Arduino would be
Relay board VCC to Arduino +5V
(signal pins to In0, IN1 etc)
EXAMPLE: Isolated Wiring for a 4-relay Board
(Same idea for 2 or 8-relay boards)

https://arduino-info.wikispaces.com/ArduinoPower 20/33
4/14/2018 arduino-info - ArduinoPower

You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

Here's the Schematic Diagram of the Optically-


Isolated Relay boards: The Ground Symbol at the
bottom is labelled "GND".

NOTE on 3.3V Signals:


It is possible to use these relay boards with 3.3V
signals, IF the JD-VCC(RelayPower) is provided from a

https://arduino-info.wikispaces.com/ArduinoPower 21/33
4/14/2018 arduino-info - ArduinoPower

+5V supply and the VCC to JD-VCC jumper is removed. .


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

That 5V relay supply could be totally isolated from the


3.3V device, or have a common ground IF opto-isolation
is not needed. If used with isolated 3.3V signals, VCC
(To the input of the opto-isolators, next to the IN pins)
should be connected to the 3.3V device's +3.3V supply
(Or the devices 5V supply if available, like
BeagleBoneBlack). You should test with your 3.3V device
to be sure. We will soon be testing with Arduino DUE ,
BeagleBoneBlack, Intel Galileo and Raspberry Pi which
are 3.3V devices.

You can control a lot of different lights, water valves,


and ventilation systems with relays like this. With some
sensors and your Software Sketch ideas, an intelligent
system may be born. NOTE: Sometimes switching these
kinds of loads can cause Electromagnetic Interference,
Arduino lockup etc. More information on handling these
problems is available HERE:

Comments, Critiques, Suggestions welcome!


terry@yourduino.com

AC vs DC: Why do I care?


When you are switching power, you care if it is AC or
DC. You care because there are different effects on
the switching elements you use, which could be metal-
contact relays, Power Transistors, Silicon-Controlled-

https://arduino-info.wikispaces.com/ArduinoPower 22/33
4/14/2018 arduino-info - ArduinoPower

Rectifiers or TRIACS.
You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

Turning things ON:


When you make the connection to turn something on,
current starts to flow. If the load is a nice pure
resistance like a heater element then the current just
starts up and stays the same. But if the Load is a motor
or an incandescent lamp, there is a sudden inrush of
current right at the beginning. Your switching device
has to be able to handle that.

Turning things OFF:


This is more of a problem. When you break the
connection to turn something off, bad things can
happen, especially if the load is 'inductive' like a motor,
a magnet, a relay coil etc. Such loads produce a sudden
high voltage in the reverse direction, that can spark and
damage relay contacts or internally damage transistors,
SCRs, TRIACS. There are two approaches to handling
this:
1. Make sure the switching device is rated to handle
this type of load. Notice that relays often have
two ratings: A resistive load in Amps, and a Motor
load in Horsepower which considers these
situations.
2. Use some method of suppressing the high voltage
transient. Like these:

https://arduino-info.wikispaces.com/ArduinoPower 23/33
4/14/2018 arduino-info - ArduinoPower

Connect a reverse diode across magnets


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

and relay coils.


Connect a MOV (Metal Oxide Varistor)
surge suppressor across the load.
Connect some resistor-capacitor
combination across the switching contacts

Turning Off AC vs DC:

It's easier to turn off AC than DC. Why?? Because AC


is constantly changing from + to - and there is an

https://arduino-info.wikispaces.com/ArduinoPower 24/33
4/14/2018 arduino-info - ArduinoPower

instant when the voltage is zero. A spark that started


You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

when the contact opened will usually stop when the


voltage gets to zero. A DC spark / arc could continue
for some time, acting like a miniature welder and
welding relay contacts together.
Some electronic circuits are made smart. They wait for
the voltage to become Zero (The "Zero-Crossing") and
then turn off. You may see references to "Zero-
crossing-switches". There are Zero-Crossing Solid
State Relays like this one (right) that can switch 25 to
50 amps. See it here:

OK, let's do some practical DC switching before we do


any more of this details stuff...

DC Switching:

DC can be switched with relays, subject to the arcing


problem mentioned above. The "Starter Solenoid" Relay
in your car may switch hundreds of amps at 12 volts.

DC can be switched with transistors. Unless you printed


this, there are millions of little DC transistor switches
running in your computer right now.

But let's use a big transistor and switch a big light on,
as an example. These days most power transistors are
"POWER FETs" - Power Field Effect Transistors. We'll

https://arduino-info.wikispaces.com/ArduinoPower 25/33
4/14/2018 arduino-info - ArduinoPower

use a
You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

small
board
with
four
Power
FETs
that
looks
like
this

(right):

(You can get one here: ) This board also has "Optical
Isolation" (See above). The isolator chips are the white
ones in the photo. The Power FETS are IRF540 types
and have a maximum rating of 100VDC and 30 Amps (but
stay below 10 Amps without heat sinks on the FETS).
This is another of the "Electronic Brick" series and it's
easy to connect each Power FET channel to Arduino
with 3-wire cables to a "Sensor Shield". Any Arduino
I/O pin can drive one of these FETs.

In use, the + and - terminals are connected to the


power source, such as 9 to 50 Volts DC. The loads are
connected to the + and - terminals of the channel being
used. This configuration is very usual and is called a "low
side switch". The load is connected to the + power, and

https://arduino-info.wikispaces.com/ArduinoPower 26/33
4/14/2018 arduino-info - ArduinoPower

the
You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

switch

connects it to GND to turn it on.


In the example on the right (An older version board!), a
12V battery is the power source and a 12V cabinet light
is the load.
In the close up photo you can see the lamp load (white
wires) is connected to + and S2.The Good Old Blink
program works fine and the DC powered lamp blinks
away happily.

But, an important difference is that a Power FET can be


turned On and Off very fast, compared to a relay. And
it doesn't wear out mechanically. So you can dim the
lamp by using PWM "Pulse Width Modulation". If the
lamp is turned on only 50% of the time, very fast, it will
be at 1/2 brilliance.

https://arduino-info.wikispaces.com/ArduinoPower 27/33
4/14/2018 arduino-info - ArduinoPower

Try
You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

out
the

following example Software Sketch "PWM Example" .


Plug the Power FET control cable into I/O pin 9 and
upload "PWM Example". The lamp smoothly fades up and
down every second. You can't do that with a relay!

This could also be used to control power of a heater, or


speed of a motor (that didn't need to be reversed). See
"Motor Drivers" for more examples and reversible
options.

/* YourDuino PWM Power Example


"analogWrite" outputs a Pulse Width Modulated signal
terry@yourduino.com
Fades an LED or Lamp up and down
NOTE: analogWrite values are from 0..255

https://arduino-info.wikispaces.com/ArduinoPower 28/33
4/14/2018 arduino-info - ArduinoPower

You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss
*/

/*-----( Import needed libraries )-----*/


/*-----( Declare Constants )-----*/
#define ledPin 9 // LED connected to digital pin 9
/*-----( Declare objects )-----*/
/*-----( Declare Variables )-----*/
int fadeValue; //Value to be sent to PWM

void setup() /****** SETUP: RUNS ONCE ******/


{
// (Not Used)

}//--(end setup )---

void loop() /****** LOOP: RUNS CONSTANTLY ******/


{
// fade up min to max
for(fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
{
analogWrite(ledPin, fadeValue);
delay(50);
} // End Fade Up

delay(2000); // Hold 2 seconds at max brightness

// fade out max to min


for(fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
{
analogWrite(ledPin, fadeValue);
delay(50);
}
delay(2000); // Hold 2 seconds at off

}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/


//None

//*********( THE END )***********

https://arduino-info.wikispaces.com/ArduinoPower 29/33
4/14/2018 arduino-info - ArduinoPower

You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

NEXT: SOLID STATE RELAYS TO CONTROL


120 or 240V AC LOADS

RE: Christmas light strings - this varies a lot with


different types of incandescent (large or mini) and LED
strings. Some good guidelines can be found here:

UNDER CONSTRUCTION:
Here is an example Software Sketch for a 8-channel
SSR board (Seen Here):
It can be cut-pasted into an Arduino IDE window.

/* YourDuino Example: 8-channel Solid State Relay Board


This board is "active high".
terry@yourduino.com */

/*-----( Import needed libraries )-----*/


/*-----( Declare Constants )-----*/
#define RELAY_ON 1
#define RELAY_OFF 0

#define Relay_1 2 // Arduino Digital I/O pin number


#define Relay_2 3

https://arduino-info.wikispaces.com/ArduinoPower 30/33
4/14/2018 arduino-info - ArduinoPower

You#define Relay_3of this


are not a member 4 wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss
#define Relay_4 5
#define Relay_5 6
#define Relay_6 7
#define Relay_7 8
#define Relay_8 9
/*-----( Declare objects )-----*/
/*-----( Declare Variables )-----*/
int waittime; // Delay between changes
void setup() /****** SETUP: RUNS ONCE ******/
{
waittime = 1000;
//-------( Initialize Pins so relays are inactive at reset)----
digitalWrite(Relay_1, RELAY_OFF);
digitalWrite(Relay_2, RELAY_OFF);
digitalWrite(Relay_3, RELAY_OFF);
digitalWrite(Relay_4, RELAY_OFF);
digitalWrite(Relay_5, RELAY_OFF);
digitalWrite(Relay_6, RELAY_OFF);
digitalWrite(Relay_7, RELAY_OFF);
digitalWrite(Relay_8, RELAY_OFF);

//---( THEN set pins as outputs )----


pinMode(Relay_1, OUTPUT);
pinMode(Relay_2, OUTPUT);
pinMode(Relay_3, OUTPUT);
pinMode(Relay_4, OUTPUT);
pinMode(Relay_5, OUTPUT);
pinMode(Relay_6, OUTPUT);
pinMode(Relay_7, OUTPUT);
pinMode(Relay_8, OUTPUT);
delay(4000); //Check that all relays are inactive at Reset

}//--(end setup )---

void loop() /****** LOOP: RUNS CONSTANTLY ******/


{
//---( Turn all 8 relays ON in sequence)---
digitalWrite(Relay_1, RELAY_ON);// set the Relay ON
delay(waittime); // wait for a second
digitalWrite(Relay_2, RELAY_ON);// set the Relay ON
delay(waittime); // wait for a second
digitalWrite(Relay_3, RELAY_ON);// set the Relay ON

https://arduino-info.wikispaces.com/ArduinoPower 31/33
4/14/2018 arduino-info - ArduinoPower

delay(waittime);
You are // wait for a second
not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss
digitalWrite(Relay_4, RELAY_ON);// set the Relay ON
delay(waittime);
digitalWrite(Relay_5, RELAY_ON);// set the Relay ON
delay(waittime); // wait for a second
digitalWrite(Relay_6, RELAY_ON);// set the Relay ON
delay(waittime); // wait for a second
digitalWrite(Relay_7, RELAY_ON);// set the Relay ON
delay(waittime); // wait for a second
digitalWrite(Relay_8, RELAY_ON);// set the Relay ON
delay(waittime * 4); // wait see all relays ON

//---( Turn all 8 relays OFF in sequence)---


digitalWrite(Relay_1, RELAY_OFF);// set the Relay OFF
delay(waittime); // wait for a second
digitalWrite(Relay_2, RELAY_OFF);// set the Relay OFF
delay(waittime); // wait for a second
digitalWrite(Relay_3, RELAY_OFF);// set the Relay OFF
delay(waittime); // wait for a second
digitalWrite(Relay_4, RELAY_OFF);// set the Relay OFF
delay(waittime);
digitalWrite(Relay_5, RELAY_OFF);// set the Relay OFF
delay(waittime); // wait for a second
digitalWrite(Relay_6, RELAY_OFF);// set the Relay OFF
delay(waittime); // wait for a second
digitalWrite(Relay_7, RELAY_OFF);// set the Relay OFF
delay(waittime); // wait for a second
digitalWrite(Relay_8, RELAY_OFF);// set the Relay OFF
delay(waittime * 4); // wait see all relays OFF

}//--(end main loop )---

//*********( THE END )***********

TO COME: Some Details: POWER, Sources and


Loads, Circuits etc.

https://arduino-info.wikispaces.com/ArduinoPower 32/33
4/14/2018 arduino-info - ArduinoPower

You are not a member of this wiki. Join now (https://arduino-info.wikispaces.com/space/join) Dismiss

Help · About · Pricing · Privacy · Terms · Support


Contributions to https://arduino-info.wikispaces.com/ are licensed under a Creative Commons
Attribution Non-Commercial 3.0 License.
Portions not contributed by visitors are Copyright 2018 Tangient LLC
TES: The largest network of teachers in the world

https://arduino-info.wikispaces.com/ArduinoPower 33/33

You might also like