Home Chapter 9 BS2 Flash an AC bulb on and off

Site Search


Chinese (Simplified) French German Italian Portuguese Russian Spanish
BS2 Flash an AC bulb on and off

In this lesson, you will first learn to use the SSR to flash an AC bulb on and off using your Arduino or Basic Stamp (bulb not supplied). You will then employ a 5-volt PIR sensor to activate the bulb into varying flashing behaviors. You will use a metro object in MAX MSP and Jitter for the Arduino or a FORNEXT LOOP in Pbasic code for the BS2 to make the event happen any number of times you would like.

Solid State Relay (SSR): Controlling AC Voltages

With the SSR, you can use a 5-volt DC voltage at 20 mA to control a 120-volt AC circuit. Now the power of sequencing begins to come to “light”. You can sequence, control, and switch most voltages as long as you select the right SSR for the job. SSRs, like their electromagnetic cousins, need a certain control voltage and amperage in order to switch much larger voltages. SSRs are available to match most controlling voltages and they function with the logic level (0-5 volts) available with most microprocessors.


Kyotto Solid State Relay. Control pins are 1 and 2 and require 3--32 volts. Switched output pins are 3 and 4. The maximum rating for these pins is 2 Amps at any voltage between 24 and 280 volts AC

One major benefit of using SSRs is that they do not create electromagnetic noise because they use optical photo couplers to switch the signals on. This allows high speed and high-frequency switching, but if you require very high-speed SSR switching, be sure to seek out the data sheet and specifications of the part you choose.

Because SSRs have no mechanical parts, they will last longer than electromechanical relays. Using light, as a switching agent does not create the noise associated with electromechanical relays. This is a benefit as the electromagnetic noise created with electromagnetic relays can cause noise in the circuits

Inside each SSR, are an LED, which creates light and a light receiver, looking for that light. When the light inside the SSR turns on the receiver also turns on and this allows you to use a light to switch the device oandan off. This isolates the larger voltage you are switching with the much smaller voltage necessary to turn the small LED on inside the SSR. This method also protects the microprocessor from the electromagnetic field that surrounds most relays.


Kyoto KB20C02A In this diagram, the number 1 is the circuit that turns the LED inside the plastic case on. The + goes to the signal from your Basic stamp output pin and the 2 and 3 show the internal switching circuits inside the plastic case. The area at 4 shows a sine wave. This refers to the AC signal.


There are many different mounting possibilities for SSRs, depending on the physical package needs, the voltage, and the current switching capabilities you require. Jameco Inc. has a nice selection of small pictures that may help to decode the many mounting and form factors that exist for SSRs. You can also do a GOOGLE search on the part and often find what you are looking for. The important thing is to select the proper SSR from the start. SSRs, like many devices, also have absolute maximum ratings.

The main considerations when selecting an SSR is: 1) How much voltage and amperage does your microprocessor provide for switching on and off, and 2) What are the maximum voltages and amperage you will be switching? Is it going to switch AC or DC and how many volts can it switch?

For example: if you need to switch 200 volts AC at 30 amps, then make sure the SSR you choose is rated in excess of 200 volts AC, and that it can also handle the 30 amps. The Basic Stamp 2 can source (provide) up to 25 mA output per pin, so if you purchase other SSRs, be aware of the required switching volts and amps to allow the circuit to function. ALWAYS confirm these voltages before purchasing future SSRs.

Manufacturers often publish data sheets about their parts on the web as PDF documents. Most electronic catalogs also publish absolute maximum ratings in their catalogs.


Data Sheets are technical specification sheets that list ratings such as absolute maximum voltage and amperage for the part.


Building the Circuit

To build the circuit, first, unplug all the previous circuits you have been prototyping on your breadboard.

The SSR in your kit comes with a power cord and extension cord outlet already soldered. Look for the red wire into PIN 1 on the Board. The blue wire goes to the ground (VSS).


Warning! AC can KILL you. Handle AC with care and be around to celebrate your inventions. Always unplug and turn off any circuitry you are working on. Double check that you have the AC extension cord unplugged when you are screwing in your AC bulb and building and programming this activity.


Parts Required

One Solid-state relay with extension cord soldered in line with the SSR. Parts supplier Jameco’s part number is 176698CG and the manufacturers part number is (KYOTO) KB20C06A-R
One AC socket with plug soldered in line and attached. local hardware store is the best source
One AC 100-watt bulb

To create this project using the Arduino you can use the same pinout and lesson plan described in activating an LED out of pin number 13. The circuit design above will be identical for the Arduino or the BS2 though the code will vary.



state relay showing pin connections to Board of Education


If you look carefully at the SSR above, you can see the extension cord, you can see that the device is just acting as an LED switch to allow the AC to be activated and turn the light bulb on. Of course, the AC cord is providing the power for the bulb and the BS2 is providing power for the LED inside the solid state relay.


Solid-state relay with light socket and light bulb


Schematic of the circuit with a PIR sensor input. The schematic on the right is for the circuit above.