Kuro5hin.org: technology and culture, from the trenches
create account | help/FAQ | contact | links | search | IRC | site news
[ Everything | Diaries | Technology | Science | Culture | Politics | Media | News | Internet | Op-Ed | Fiction | Meta | MLP ]
We need your support: buy an ad | premium membership

Controlling a light with your Personal Computer

By marcos in Technology
Wed Jul 03, 2002 at 08:41:25 PM EST
Tags: Hardware (all tags)

Many of us have often wanted to interface our computers with real life gadgets. It isn't a difficult or complex task, and it doesn't cost much. There are a number of websites with instructions on how to do this, but often the descriptions are unnecessarily complex and suppose a lot of fore-knowledge in electronics.

I would like to show how to build a simple electronic board that will allow you to use software installed on computer to flick a number of switches which are connected to your parallel or serial port, and all for less than 5 Euro ($5).

At the same time, I will introduce you to practical effects in a circuit of various electronic components such as diodes and transistors.

About the article

This article does not assume any training in electronics. Explanations of various components will be given, but only so much as will allow you to understand what you are building without fully understanding the details of the components.

I am not a trained electrician or electronics engineer. I may make a few mistakes, so please be lenient, and correct me nicely.

Also, you can simply buy a board that will allow you to switch lights with your personal computer. If you prefer to that, there are links in appendix 1 to various websites that sell boards that will allow you to do so.

These commercial boards are often a bit more expensive than simply getting the individual components and soldering them together. If we build the board ourselves, the combined cost of all the components we will use will come to just a bit over 5 Euro. Appendix 2 lists the item numbers of all components we will use for the Conrad.de store. This is probably only useful for people in Germany. Non-German readers should take a look at Appendix 3.

The basics of electricity

If you are familiar with current and voltage, you can skip this bit.

Potential difference and voltage

An electrical voltage is the difference in potential between two points. For example, a 5volt battery is labelled on one end +, and on the other -. This means that there is a potential difference between the + and - ends of 5 volts. If you connect the two ends, the battery will seek to make both ends have the same voltage, and so current will flow from - into +.

You can think of it as a can of water, one end of which is full, and the other empty. The empty end is also very much larger than the full end. If you connect them together with a pipe, water will flow from one can into the other till they have the same level of water. This level will be very low because the empty bucket was much larger, though.

Potential difference is indicated with the V symbol, which stands for volt. The + and - symbols indicate which side of the circuit has excessive potential, and which has a lower or 0 potential.

Electrical Current

Current, indicated with the A (ampere) sign, is the flow of electricity as it tries to balance out the potential difference. If you have a potential difference of 5v across two points, there will be a flow from the higher potential to the lower potential. That is the current.

A higher voltage will cause a larger current, much in the same way as a pipe connected to a large tank will cause a stronger flow of water from a pipe connected to it, when compared to a small can of water.

So obviously, there is a relationship between potential difference and current. This relationship is described as V=IR. R is the proportionality constant between the two values, and is called the resistance.

A short introduction to circuit boards and the components we will use

This is the circuit we will use to build our relay board that will be controlled by the personal computer.


  • This is the site where I get all the diagrams and descriptions of the circuit from.
  • If you understand the circuit and the components that are indicated there, then you might want to skip this bit.
There are a number of electrical components that all behave differently when they are placed in an electrical circuit. These components are all represented with different symbols.

The circuit board

The board looks like your PC main board - you know - that green thing in your computer. It is a physical thing, and the picture above is merely a representation of it.

The lines represent current carrying connections between the various components. The symbols all represent different components, which will be described here.


A resistor is a component that reduces the current in our circuit. Like the name already says, it acts as a resistance against the current. If you introduce a large resistance into a circuit, the current will drop proportionally.

Resistors are measured in ohms (Ω). A typical resistor is colour coded to enable one recognize its value. A description of the colour coding is available here.

This is how the resistor is represented in a schematic, such as the one above:

       |            |                                                    

A square represents a resistor. You can view a gif image of the square here. Sometimes (but not in our circuit diagram above), resistors are represented with zigzag lines. An example is here.


A Diode is a simple electrical component that only allows current to flow in one direction. When the current is reversed, for example by switching the negative with the positive pole, then the diode acts as a very large resistor, and blocks the current from flowing.

This has a limit however - if you screw the current too high, the diode will go kaput and allow current to flow in the wrong direction.

The diode is represented with this symbol:

     | /|      
     | \|  

Gif image available here.

The diagram shows us in which direction the current will flow. The arrow points at the flow direction and the vertical line show the direction which will block the current.


We all know LEDs. Those little green lights you probably have in front of your computer. Well, L.E.D. is an acronym for "Light Emitting Diodes". Yes, that is right, a LED is just a diode like described above. Well, it also emits light:

      ~ ~
    | /|
    | \|

Gif image available here.

You see, the symbol is the same as that of a diode, but has a few squiggly lines which I suppose are to indicate the light being given off.


A relay is basically a switch. It is a mechanical switch that you can control by applying a current to it. When you apply a current, it flicks the switch to the on position. When you turn of the current, it turns itself to the off position. There are other types of relays (like solid state relays), which toggle themselves when you apply a current, and do nothing when you turn off the current.

This is a photograph of a relay.


A transistor is similar to a relay; the main difference is that it is an electronic switch.

This is how a transistor looks like:

---B   |

View gif image here.

To put it simply:

  1. The wire sticking out of the bottom (emitter) with an arrow on it leads to the negative pole of the battery, also called the mass.
  2. The wire pointing towards left (basis) controls the switch. If a voltage is applied there, then there will be current flow from the wire pointing upwards through to the wire pointing downwards. The switch would then be on. If there is no voltage in the wire pointing left, the switch is in the off position.
  3. The wire pointing upwards (collector) carries the current that we want to switch on and off.
That is a very simplified description of a transistor and how it functions in a circuit. The internal functionings of a transistor are a bit more complex.

The circuit board and how everything works

*** Link to diagram. Editor should replace this text with the image itself ***

The board pictured above is the board we will build. The board is made up of only the components we have described above.

The diagram above is schematic ¨C it serves to show us how the connections between the various components is going to occur, but does not really represent how our physical board will look like.

This is a photograph of the finished board.

The interaction of the components

Note the following about power sources:

  • Our parallel port provides us with 5V, 2mA
  • We connect an external 5v supply to control the relay to the poles marked +5v
  • The relay can switch up to 16A. My washing machine needs a 16A switch, for comparism
We have a 5volt current coming out of our parallel port. Our goal is to use those 5volts to regulate a 220volt current. We will thus examine the circuit from the lower left hand side, and see exactly what occurs.

There are three current flows in the circuit. There is the current flow that is provided by our parallel port, and is switched on and off with the PC. There is the current from an external 5volt device, and which is switched on an off by the parallel-port current with the transistor. There is the 3rd current that is isolated from our components, and switched by our relay.

When we provide the 5volt potential difference from our parallel port

  • The transistor is switched on, and acts as a switch for the 5v external power supply. There is a resulting current flow through the LED, and through the relay
  • The LED goes on, and the relay switches itself on. The relay thus flicks the electrical appliance we have connected to it into the on-state.
That has explained the workings of the circuit in general. You are wondering why we need all those other diodes and resistors, are you not?
  • The resistors keep our current at sane levels. If we didn't have a resistor, our current will be way too high, and our other components will die fiery deaths
  • The LED is just there to tell us when the circuit is switched on
  • The diode D2 is there to protect us from ourselves: if we swap the negative and positive poles, it isn't very good for our transistor. With the diode D2 present, we simply short-circuit the wires, and protect our transistor
Building the board

Once you understand the theory, then building the board is a snap. First of all, you have to buy all the components; Appendix 3 has a list of all the components you should get. Those living in Germany should look at Appendix 2.

When you have the components, you plug all the components into the board following this diagram.

There is nothing complex about this, if you plug everything in exactly as the picture shows, then you have built the circuit we looked at above. Dotted lines indicate a part of the board where the current carrying path should be sliced through to prevent current passing.

The circle with the slash-through indicates a screw.

When everything is done, you will need a soldering iron and some solder lead. Solder all the components to the board, and you are done! Remember to make sure that everything was connected BEFORE you solder, and not after ;)

Check that you connections are OK with a resistance measuring meter, after which it is recommendable to test with two external power sources such as adapters or batteries and not directly with your PC parallel port yet.

Programming the board

After you have verified that your board is working properly, you will want to trigger the board on and off with your computer. For this, you just need to provide 5volt to the transistor circuit. These 5volts can come from your parallel port interface.

This page describes which of the parallel port pins will supply the 5volt. German speakers will find this resource detailing the parallel port and it's programming useful. This resource describing the parallel port in detail should also be read by all who want to further understand what they are doing. This page too.

You will need to switch off the single bits of the port independently. If you wish to roll your own code, this site has got a good number of samples on how to do it. If you prefer readymade parallel port controlling software, then that site has some.

But your premier source for parallel port switching software should be DiscoLitez.

Download the software, plug in the board, and start switching.


  1. Links to websites that sell ready-made relay boards:
  2. List of components we use, and their order numbers at Conrad.de. This list is only relevant for users in Germany and neighbouring countries, so it isn't translated for their convenience
    • Relais-Leistungsrelais GER-1-E, 6 V   [Order Number: 503916]
    • D1-Universaldiode 1 N 4148        [Order Number: 162280]
    • D2-Universaldiode 1 N 4148       [Order Number: 162280]
    • T1-Darlington-Transistor BC 517   [Order Number: 154695]
    • LED-LED 3 mm grün                 [Order Number: 184713]
    • R1-Widerstand 1/4 W 5%  150 Ohm   [Order Number: 403156]
    • R2-Widerstand 1/4 W 5%  100 K-Ohm  [Order Number: 403490]
    • R3-Widerstand 1/4 W 5%  1 M-Ohm  [Order Number : 403610]
    • Schraubklemme 2-pol              [Order Number : 729787]
    • Schraubklemme 3-pol              [Order Number : 729795]
    • Stiftleiste                      [Order Number : 743992]
    • Rasterplatine                    [Order Number : 527629]

  3. List of all the components we need, in English, and without order numbers.
    • One Relay, that requires 6 V to switch, and can switch up to 16A
    • Two Diodes: 1 N 4148
    • One T1-Darlington-Transistor BC 517
    • One LED-LED 3mm Green
    • Resistor (1/4W 5%) 150 Ohm
    • Resistor (1/4W 5%) 100 KOhm
    • Resistor (1/4W 5%) 1 MOhm
    • Connector 2-poles (see picture here)
    • Connector 3-poles
    • Circuit board

    Photograph of all the components.


Voxel dot net
o Managed Hosting
o VoxCAST Content Delivery
o Raw Infrastructure


Top way to get thrown out of chemistry lab?
o Pretend an electron got stuck in your ear, and insist on describing the sound to others 9%
o Give a cup of liquid nitrogen to a classmate and ask, "Does this taste funny to you?" 16%
o Consistently write three atoms of potassium as "KKK." 2%
o When it's very quiet, suddenly cry out, "My eyes!" 10%
o Deny the existence of chemicals. 9%
o Begin pronouncing everything your immigrant lab instructor says exactly the way he/she says it. 9%
o Pop a paper bag at the crucial moment when the professor is about to pour the sulfuric acid 15%
o Show up with a 55-gallon drum of fertilizer and express an interest in federal buildings. 26%

Votes: 184
Results | Other Polls

Related Links
o This
o This [2]
o here
o here [2]
o here [3]
o here [4]
o here [5]
o This [3]
o here [6]
o Link to diagram. Editor should replace this text with the image itself
o This [4]
o this
o which of the parallel port pins will supply the 5volt
o parallel port and it's programming
o parallel port in detail
o This [5]
o roll your own code
o readymade parallel port controlling software
o DiscoLitez
o Analog Input Board
o Digital I/O Boards for PCI Bus Computers
o Photograph
o Also by marcos

Display: Sort:
Controlling a light with your Personal Computer | 67 comments (30 topical, 37 editorial, 0 hidden)
It tastes like burning! (1.00 / 1) (#29)
by Weakon on Wed Jul 03, 2002 at 06:03:06 PM EST

At least people can get your email addy when they electrocute themselves following this post. The best way to learn about electronics is to break a toaster.

Control a light? (4.40 / 5) (#31)
by ilnp on Wed Jul 03, 2002 at 06:15:37 PM EST

What everyone really wants is to flush their toilet remotely via telnet. -daniel

Already done. (4.00 / 2) (#52)
by raygundan on Thu Jul 04, 2002 at 01:47:57 AM EST

Years back as an intern I helped put something together to do just that.  (Note: I'm using "helped" in its loosest sense-- I was only peripherally involved with that project) It was a control system that would be sold to prisons, with toilet, shower, and sink control all in one handy unit.

Sadly, I can't seem to remember the name of the company we were contracting for.  Anybody know a company that makes stainless steel bathroom fixtures for prisons that also sells a toilet control box?

[ Parent ]

funny poll (none / 0) (#35)
by dirvish on Wed Jul 03, 2002 at 07:01:10 PM EST

I only read the poll, but that is enough for a +1.

Technical Certification Blog, Anti Spam Blog
I've learned more (4.00 / 1) (#37)
by JChen on Wed Jul 03, 2002 at 07:33:22 PM EST

from this article than I have from my various electrical engineering friends. Thanks for putting up with us commoners.

Let us do as we say.
Non-US-Centric! (4.00 / 1) (#38)
by epepke on Wed Jul 03, 2002 at 07:54:40 PM EST

In the U.S., the symbol for a resistor is usually -/\/\/\/-

And your box isn't going to look the same on all browsers.

The truth may be out there, but lies are inside your head.--Terry Pratchett

As in here (none / 0) (#58)
by Strange on Thu Jul 04, 2002 at 12:42:50 PM EST

In Portugal we use that same symbol, not the box.

[ Parent ]
too bad (none / 0) (#63)
by bigelephant on Thu Jul 04, 2002 at 03:27:17 PM EST

Actually, the European standard is the rectangle.  Makes more sense, anyway - the US symbol looks like a coil or solenoid and is also hard to draw.

[ Parent ]
Electronic component symbols (none / 0) (#65)
by csmiller on Thu Jul 04, 2002 at 05:03:11 PM EST

The UK symbol for the resistor was the squiggly line around 10-15years ago, it is now the box.
The old one has the advantage that it can be drawn with in one fluid movment, and (to me) symbolises a long wire, which was how the wire-wound resistors were made.

The symbol for a inductor/transformor is below. Whether the pararrel lines are dashed or solid indicates that the inductor is air or ferric cored.

) ||
) ||
) ||
) ||
) ||

BTW. why doesn't K5 support <PRE>?, yes it can be abused, but so can most HTML

[ Parent ]

Resistor vs Impedance (none / 0) (#66)
by Enocasiones on Fri Jul 05, 2002 at 07:08:23 AM EST

While studying engineering I learned the rectangle is for impedances (represented by Z; they don´t just have resistance, but a reactance too, either a capacitance or an inductance), while the squiggly line is for true resistors (R). Of course you can represent them all with a rectangle if you point out the imaginary value is zero for pure resistors...

[ Parent ]
Interesting Article, but.... (4.00 / 1) (#41)
by TimM on Wed Jul 03, 2002 at 08:55:44 PM EST

Very good article explaining the basics of electronics! However, the only real advantage I see to this method is if you're strapped for cash or like doing things yourself. If you aren't, and you're not good at electronics, I'd recommend X10. It's a company making pieces of hardware that let you distribute appliances and lights throughout the house, and control them via RF (radio waves, essentially). You just send a signal, and a light several rooms away comes on. Or anything else that plugs in to the wall.

My setup includes several lights, a couple of fans, and some kitchen appliances. I also have a motion sensor set up in my closet to turn its lights on automatically when I walk in. I can also program the whole thing on my computer and control lights when I'm not home to make it seem like I am.

Another company that does similiar things is SmartHome. Same kind of setup, but a variety of manufacturers, many of which are cheaper, and more complicated stuff. Again, good article, but for others, including myself, electronics building isn't our strong point, so just pointing out there are alternatives to those who don't know. :-)

(Disclaimer: I am not an employee of either company, nor do I intend this to be a spam. Just a user of said products)

Ah, but... (5.00 / 2) (#49)
by TheOnlyCoolTim on Thu Jul 04, 2002 at 12:03:08 AM EST

Considering all their pop-up ads, no one should ever buy X10.

"Secure your home by putting cheap cameras where they will see hot chicks in bathing suits!"

"We are trapped in the belly of this horrible machine, and the machine is bleeding to death."
[ Parent ]

Smart homes in the UK? (none / 0) (#56)
by Mwongozi on Thu Jul 04, 2002 at 10:28:26 AM EST

Does anyone know of a site like SmartHome that sells stuff designed for the UK?

[ Parent ]
Design review (5.00 / 4) (#42)
by tftp on Wed Jul 03, 2002 at 08:57:44 PM EST

The R3 resistor is not really needed. This is because the impedance of the PC output in series with R2 (100K) will be less than 10% of the value of the R3. The issue of "hanging base" can be dealt with by replacing the diode in base with a Zener diode (as it is normally done for protection against static).

Relais-Leistungsrelais GER-1-E, 6 V

This is wrong relay for the job. You will get voltage drop on the silicon transistor about 0.7V, and with the supply +5V the relay won't switch.

This is the wrong design anyway - you should use an optocoupler instead. Then you will insulate the PC from your power supply. This is -very- important because relays short to the coil or to the metal can sometimes, and that will fry your PC. The optocoupler will also eliminate the resistor R3 and the diode next to it. Some optocouplers will be able to switch the relay directly, so transistor will be gone as well. Here is one of them, and there are thousands of products to choose from.

Request for advice (2.50 / 2) (#44)
by jasyoung on Wed Jul 03, 2002 at 09:46:48 PM EST

Since this story will gather some people with a clue about electronics.. I have a radar detector hardwired into my car, but it's wired into an always-on source of 12V. I have a conveniently available ignition-switched line nearby, but it doesn't provide sufficient current to operate the device. It's a switch line for the sunroof apparently output by the onboard computer or similar, as it's a perfect 12V at all times instead of the 14-15V you get when the alternator's running.

So given these things:
12V battery source
12V ignition-switched, low current

I want to arrange for my radar detector to be powered only when the ignition is on, from the 12V battery source. I need a relay of some sort, I know, but the array of types available is bewildering. Can anybody tell me exactly what I want here?

more current for your radar detector (5.00 / 1) (#45)
by Brandon Stafford on Wed Jul 03, 2002 at 10:53:46 PM EST

It depends on how much current you need, but a N-channel power MOSFET would probably do the trick. You could get one (try the IRLU2905) from Digikey, or some similar place, for a few dollars. It acts like a voltage-controlled switch that needs almost no current to turn on.

MOSFETs have three terminals: gate, drain, and source. For your radar detector, you should hook the source to ground, the drain to the minus side of your radar detector, and the gate to your low-current 12V line. The plus terminal of the radar detector should be hooked to the positive side of the battery. (Don't worry about the fact that "drain" and "source" seem backwards. They refer to electron motion, which is opposite from current flow. Stupid, but that's the way it is.)

When you turn on your ignition, the low-current line will rise to 12V, and the MOSFET will turn on. This will allow the radar detector to get current from the battery.

A few other things: lots of other MOSFETs will work-- just make sure you get one that says N-channel on it. Depending on how much current the detector needs, you may also want a "power" MOSFET. A non-power MOSFET will probably work for a little while, but eventually, it will get really hot and burn out.

You could also use a relay, but they are more expensive, less reliable, bigger, and make noise.

Almost any NPN transistor would work too, but they're a little more complicated to explain-- you'd need a resistor to keep it from burning up.

Let me know if this doesn't make sense.


[ Parent ]

Thanks! (none / 0) (#47)
by jasyoung on Wed Jul 03, 2002 at 11:46:12 PM EST

Looks simple enough based on your instructions. I ordered the IRLU2905 part for the job this evening. I ordered three actually, one to finish my car, one to do the one in my wife's truck, and a third for when I screw up at some point. Thanks for the advice!

[ Parent ]
That will make his radar detector look broken. (none / 0) (#48)
by ninjalex on Wed Jul 03, 2002 at 11:49:10 PM EST

N channels are statically conducting. When you turn on the key in the circuit you described, the 12v will be WAY above the pinch off voltage for the FET and the ground path for the radar dectector will be essentially open. Use a P channel FET and it'd work fine though.

[ Parent ]
It's not quite as simple as that (none / 0) (#50)
by marxmarv on Thu Jul 04, 2002 at 12:37:00 AM EST

I haven't designed with MOSFETs lately, but the simplified circuit has two potential problems:
  1. The sunroof control may not be a mechanical switch, and leakage from whatever could cause the MOSFET to turn on (off?) continuously.
  2. The sunroof control might be a mechanical switch or could be a dirty signal for other reasons, such as ignition noise etc. The ignition noise could exceed the 16V Vgs of the MOSFET, which would be Bad.
Maybe you'd have enough power coming from the snroof lead to power a small (3A) relay, which I'd think would easily switch a radar detector on or off.


[ Parent ]

Lost in the transfer I think (none / 0) (#51)
by ninjalex on Thu Jul 04, 2002 at 12:54:04 AM EST

I think the post a couple levels up was talking about tying into the ACC off the keyswitch, which should preclude any inductive kick from the sunroof motor causing problems. Surely the motor would have a built in diode to soak that up? Good point on the Vgs(I'd forgotten it was that low, I was thinking 25V for some reason), most people forget 12volts in a car is usually 13.5 to 14V which doesn't give you much room for noise spikes. Radar detectors don't eat much current. One could probably get away with tying it in to the power for the stereo, no muss, no fuss.

[ Parent ]
Vgs and static conduction (none / 0) (#53)
by Brandon Stafford on Thu Jul 04, 2002 at 01:55:11 AM EST

Lots of good points there.

You're right about the Vgs being on the low side. I bet it will work, but I wouldn't be surprised if the alternator eventually fried it.

The point about static conduction is good too. I should have suggested a 1k resistor between the gate and ground, so that the MOSFET is forced off when the 12V is disconnected. I had been thinking that the ignition would switch the gate between 12V and ground, but it's more likely that turning off the ignition would leave the gate connected to nothing.

And yeah, hooking it to the radio would be even simpler.

Standing (well, sitting) corrected,



[ Parent ]

N channel FET's (none / 0) (#55)
by ninjalex on Thu Jul 04, 2002 at 09:09:12 AM EST

N channel FET's are normally on. You have to turn them off. IIRC, the pinch off voltage(point where it turns off) is around 3V...... We pause this post for an update aquired from google....... I'd totally forgotten about enchancement mode MOSFETS. When I work with MOSFETS, they are always depletion mode. I'll go sit in the corner now. hehehe

[ Parent ]
Stability of keyswitched power (none / 0) (#59)
by jasyoung on Thu Jul 04, 2002 at 12:57:06 PM EST

I measured the output of the key-switched power line and it was a continuous exact 12V, as opposed to the variable 14-15V on the "normal" battery feed because of the alternator. I'm of the opinion that this is a pretty clean and stable source of power. Do I need anything other than that MOSFET?

[ Parent ]
controlling the MOSFET (none / 0) (#61)
by Brandon Stafford on Thu Jul 04, 2002 at 01:44:15 PM EST

The 12V will turn the MOSFET on fine. Two problems:
1. Are there noise spikes that you can't see with a multimeter on the 12V line that will eventually damage the MOSFET? I wouldn't worry about this yet-- you can't fix the problem easily, and the failure would be non-catastrophic. I'm not sure whether the MOSFET will fail on or off (I would guess on, but I don't really know), but the result will just be that your radar detector stays on or off until you replace the MOSFET. Your radar detector will not, for example, explode into a fiery rain of molten metal.
2. What happens to the gate line when the ignition is turned off? I bet that it is left floating, i.e. not connected to any voltage source. Checking this with a multimeter is a little tricky, because a multimeter tends to pull voltages in the direction of its reference. If the gate is left floating, you should be able to measure 0V between the line and ground and 0V between the line and 12V. What's really happening is that your multimeter is altering the voltage it's trying to measure.

If the gate line is left floating, you can fix the problem with what's called a pull-down resistor. It's size doesn't matter very much (1k ohms to 100k would be work; 10k would be great). You connect it between the gate and ground. It's just a normal resistor used to pull down floating inputs-- you don't have to ask for anything special at Radio Shack (like you don't ask for "cereal milk" at the grocery store).

When the ignition is on, 1.2mA (that's 12V/10k) will flow between 12V and ground. The voltage at the gate will be 12V, and the MOSFET source is still hooked to ground, so the MOSFET will turn on.

When the ignition is off, the charge that had accumulated in the gate will be pour out through the pull-down resistor. All this charge will be gone in a microsecond or so. When that current stops flowing, there will be no voltage across the resistor. Both sides will be at ground, and the MOSFET will turn off.



[ Parent ]

another way to look at it (4.00 / 1) (#46)
by decrocher on Wed Jul 03, 2002 at 11:17:23 PM EST

   A potential difference can be thought of as a force acting on electrons in a wire.  In your example, voltage would be the weight of the water pushing down on itself.  After awhile, equilibrium is reached when the two containers have the same height of water.  No difference in height/force corresponds to zero voltage.

   Current was explaned pretty well as the actual "flow" of electrons.  You can think of watching a point on a piece of current-carrying wire and counting how many electrons go past in a certain ammount of time.

   Its not quite correct to say "220 volt current".  The two things are related but you need to specify at least two out of three numbers (for the V=IR equation) to make sense of that statement.  You knew that, but its a common mistake.
   In the winter, a potential difference much much greater than 220V can exist easily between your fingertip and, say, a younger sibling.  But the current is almost nothing.  Also, in the U.S. one would usually say "120 volts" :)

  great topic for an article and awesome poll.


PS. www.digikey.com, www.jameco.com, or www.mouser.com are good sources of mail-order electronics for US/Canada.

Slow down there, cowboy (3.00 / 2) (#57)
by ennui on Thu Jul 04, 2002 at 10:57:54 AM EST

It's generally not a good idea for the average person to be playing around with the stuff coming out of a wall socket with homemade junk. Spend the five pound more and buy an x10 kit, it controlls lights and more, comes with free software, probably won't electrocute you, and won't invalidate insurance claims the way a breadboard with a 16 amp relay jury-rigged to an outlet might.

"You can get a lot more done with a kind word and a gun, than with a kind word alone." -- Al Capone
not if you do it carefully (none / 0) (#64)
by bigelephant on Thu Jul 04, 2002 at 03:34:35 PM EST

There is nothing scary about wall power.  While I would agree that this is not a good first project, it is possible to safely work with wall power.  I certainly wouldn't use perfboard for it, but given that everything is made carefully and put in a plastic case, it would be pretty hard to start a fire or electrocute yourself.  GFCIs and circuit breakers provide quite a bit of protection, if you don't do really stupid things.

[ Parent ]
A few questions (4.00 / 1) (#60)
by QuoteMstr on Thu Jul 04, 2002 at 01:42:01 PM EST

Forgive my naivety in electronics, but I'm trying to understand how this works..

Wouldn't the LED fry? It seems backwards here, since if the current is flowing from the 5v external - pole to that end of the LED, it would act as a diode. The current coming out of the base of the transistor is still negative, but it's connected to the positive end of the LED. Also, wouldn't most of the current go by way of D1, since there's far less resistance along that path than through the LED/resistor?

I assume that + on the parallel port would be on and - would be off, right? If so, wouldn't current flow from the mass, through D2, back through R2 and just short circuit?

Also, what would happen if R3 were just removed completely?

a few answers :) (5.00 / 1) (#62)
by bigelephant on Thu Jul 04, 2002 at 03:14:31 PM EST

I think you are confused about current flow.  Current flows from + to -.  ELECTRONS flow from - to + but that's irrelevant here.  The LED won't fry.  Current will flow from the +5V power supply, through the resistor, and then through the LED and transistor to ground.  The resistor limits the current through the LED.  If the LED was in reverse, it would not let any current through and would not light.  If you took out R1, the LED would probably fry because all the current from the power supply would go through it.

No current will go through D1, since it is wired in reverse.  It is there to absorb the inductive kicks from the relay, so that the transistor doesn't get fried.

Once again, there will be no short circuit because current flows from + to -, not the other way.

R3 is there to provide a pull-down, to keep the input from floating.  If you remove it, you could get some erratic behavior with some ports.

[ Parent ]

Nice article (none / 0) (#67)
by MickLinux on Mon Jul 08, 2002 at 12:50:01 AM EST

About 3 years ago, our church was making a nativity scene creche, and I wanted to have controlled lighting.  So anyhow, I couldn't find a way to control any lights with my pc, and I wanted to control about 12 lights / strands of xmas lights all at once.  

So anyhow, I went out and got a breadboard, a 555 timer, a couple counters, a bunch of resistors and power mosfets [silly me, some of them were SOIC... I couldn't use those, I'm not good with a soldering iron, not that good anyhow.]  

And I breadboarded together my lighting.  With a little bit of control, and selection of lights, I got a sun on the background to progressively set, and twinkling stars to come out, and a fireplace inside the inn to light up and flicker.  

It was all battery powered [that has advantages and disadvantages], and only lasted for about 1/2 an hour.  

Also, since my 555 timer was only set via capacitor/inductor, it wasn't very stable, so there were about 3 minutes of warmup time.

Retrospectively, if I were going to do it again, I would:

(1) buy an external drive case, with its own power supply for mounting the parts.

(2) Run the thing with one or more cheapo PIC16 chips, and have the PIC16 chips connect to the serial i/o of a real computer, at least for downloading instructions.  Preprogram the chip to allow downloadable instructions.  Since there will be at least 30 bytes of unused memory, that allows at least 15 preprogrammed states uncompressed, better if you work out a reasonable data format.

These days, you can get an 8-pin PIC16 chip for about US$1, and since it has a stable timer on board, there is no reason to have to buy a 555 chip.  

I make a call to grace, for the alternative is more broken than you can imagine.

Controlling a light with your Personal Computer | 67 comments (30 topical, 37 editorial, 0 hidden)
Display: Sort:


All trademarks and copyrights on this page are owned by their respective companies. The Rest © 2000 - Present Kuro5hin.org Inc.
See our legalese page for copyright policies. Please also read our Privacy Policy.
Kuro5hin.org is powered by Free Software, including Apache, Perl, and Linux, The Scoop Engine that runs this site is freely available, under the terms of the GPL.
Need some help? Email help@kuro5hin.org.
My heart's the long stairs.

Powered by Scoop create account | help/FAQ | mission | links | search | IRC | YOU choose the stories!