Digital dimmer using atmega8
This project is used to control the brightness of the lamp or can be used to control the speed of the fan.
The system consists of 3 block they are
- Zero crossing detector
- Microcontroller (Atmega8)
- Load Driver (BT136)

As the name implies the zero crossing detector generates pulses for every zero crossing of the input AC signal. This pulses are fed to the microcontroller interrupt pin through the opto coupler. The opto coupler is used for the isolation of the high voltage AC to the low voltage DC supply at the microcontroller side.
The microcontroller was interrupted for every zero crossing which switch on the TRIAC as per the user need. The user can increase or decrease the output voltage with help of 2 push buttons.
The TRIAC BT136 is used to drive the load. It can withstand a maximum load of 5A. You can also use an opto coupler at the TRIAC firing side.
Circuit Diagram
Bascom Code
$regfile = "m8def.dat"
$crystal = 4000000
Config Pinb.1 = Output ' Gate Triac
Config Pind.7 = Input ' Key Up
Config Pinb.0 = Input ' Key Dn
Config Int0 = Rising
On Int0 Int0_int ' Initialise the INT0 Interrupt
Enable Interrupts
Enable Int0
Dim E As Eram Byte
Dim B As Byte
Dim D As Byte
If E > 9 Then E = 9
B = E
D = 0
Set Portb.1
Do
If Pind.7 = 0 Then
If B > 0 Then Decr B
Waitms 10
E = B
End If
If Pinb.0 = 0 Then
If B < 9 Then Incr B
Waitms 10
E = B
End If
Loop
End ' end program
Int0_int:
Set Portb.1
For D = 0 To B
Waitus 200
Next D
Reset Portb.1
Return
Download
Similar Posts
- Stepper motor Control with Atmega16
- Connect 2 microcontrollers through serial port
- Simple calculator using avr microcontroller

3.07.2010 at 6:23 PM
Can U tell me the simulation software's name that U use in this project?
Thanks in advance.
3.17.2010 at 11:05 AM
Its BASCOM, you can get it from www.mcselec.com
8.25.2010 at 6:04 PM
BR1 is connected directly to 220v (what type for example)? (without transfomer?)
is it possible to use diode except bridge?
asking just to be sure.
thank you.
3.13.2011 at 11:19 PM
Awesome project!
I have one question though.
What part is the zero crossing detector more specifically? Where can i get it? I would be really happy if you could email me the name of the part or a datasheet or similar.
Anyways, thanks, keep it up!
Best Regards,
Max
4.16.2011 at 1:32 AM
thanks dear this is a grate side for bascom avr. i need ur help in a project that is same as ur bluetooth base smart home accept water pump electric consumption i read the amp of motor and volt but i need to read the current pf of motor,do u have any idea about calculating the power factor of electric motors in single and three phase.pls help me. thanks in advance
6.15.2011 at 12:01 AM
Hi dear, I need the PCB FILE, Can U help me please?
6.28.2011 at 6:58 PM
Hi,
Do I must connect external quartz, VCC, GND on ATEMGA8?
6.28.2011 at 7:01 PM
Hi,
Do I must connect external quartz, VCC and GND to ATMEGA8?