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