Controlling Lights
Intro
|
Controlling a light is probably the most known action a domotica system can do. And it makes life easier, so here's a tutor that tells how to do it.
This tutor assumes that you don't need a normal light-switch anymore, so you'd better take a look at the switches tutor if you want to control the light with the old switch.
|

A normal relay.
|
Add-ons
Take a look at the following tutors that can extend the functionalities:
Parts
- Relay (normal elec.mech.) or Solid State Relay
- Soldering Iron
When using normal electromechanical relays:
- 2x 1k ohm resistors
- NPN Transistor
- Diode - 1N4004
Schema & Hardware
Parallel port with data, control and status pins marked:
The circuit:
When using a Solid State Relay, you can connect it directly to the parallel port (GND and one of the data pins)
Software
Take a look in the Software section for the program "position".
You will probably need to adjust the source code to match the adress of your ports.
The program works like this, you have 8 outputs, and 9 is all of them... with the s parameter you set a pin and with the c you clear it, with x you switch it. like this:
position c1 s3 x5
This will set pin 1 off, pin 3 on and switch pin 5 (actually these are pins 2, 4 and 6 on the parallel port) at the same time.
Now there are more parameters, like P, wich will pause a given number of seconds and p wich will work the same but in microseconds, eg:
position s1 P3 c5 p500000 s5
This will set pin 1, wait 3 seconds, clear pin 5, wait 0.5 seconds and then sets pin 5.
And then there is the loop parameter L wich loops everything that follows for a given numer of times or forever if the number is 0. eg.
position L0 x1 p50000
If this is connected to your lighting this will give you a headache, it just keeps switching it on and off every 50000µs
Some technical information
The NPN transistor and the external power supply are used to have enough power to drive the relay. The parallel port itself can be used to drive one or two relays, but when using more you'll be forced to use this method. When using SSR though, there's enough power so you don't need the external supply.
If you like to control the light with your old light-switch, you'll need to buy a relay with a 3-way switch, and if needed replace your current light-switch (1-way to 3-way or 3-way to 4-way)
We discourage this circuit because the computer doens't know when the light is on or off without a sensor or something. You only can switch the light using the computer, but you aren't sure if you've turned on or off the light.
|