version 2 - using capacitors and triacs

Capacitors taken from a off the shelf fan regulator have been used to
vary the speed of the fan.  Using zero detection and firing the triac in
version 1 was causing noise in the fan as the current increases from
zero immediately.   hence, capacitors are used.   On the input side,
there are two relays - one for light and the other for fan.  If Arduino
is powered off, then the NC ports of the relays are connected and hence
wall outlet switches will work normally.  When the Arduinos is powered
on, then these relays are active.  From the light relay, the NO port is
connected to a triac which can be trigged to switch on the light.  The
NO port of the fan relay is connected to three capacitors.  There are
also four triacs, one connected directly to the output and other through
the capacitors.  Based on how many triacs are triggered, the fan of the
speed varies.  But if only the triac connected to the output directly is
fired, then the fan rotates at max speed.   There is one 4 digit 7
segment display that displays the temperature reading from a Dallas
18B20 sensor and another one segment display that display fan speed, 0 -
6.  The temperature is periodically checked and if it goes below 22
degrees Celsius, the fan is switched off.