Everyone of us wants to control a bulb, a fan etc at some point in time. We will look at driving single phase AC devices with a Relay using Atmega32.

Basics

The relay is driven using a simple transistor switch circuit. You may look at the schematic of the driver circuit from Ultra AVR Dev Board Schematic. It is a common collector transistor switch circuit. It provides additional current required to drive the relay. The current from the controller port pin is not sufficient, hence the driver is used.

Be careful while driving AC loads. It can be quite dangerous. Do not turn on the mains power while hooking up the circuit. You've been warned!

Hookup

The Ultra AVR Dev board comes with Relays on board. You simply need to hook up the relay inputs with the the port pins as shown in the figure below.

Controlling AC device using Relay AVR bb.png

The Code

The code turns ON and OFF the relays, every 5 seconds.

Demo

0Lightbulb.gif

Video Tutorial

For those of you, who would like to watch instead of read we have made a video with all the gyan.


Downloads

Download the complete project folder from the below link: https://github.com/ExploreEmbedded/ATmega32_ExploreUltraAvrDevKit/archive/master.zip


Have a opinion, suggestion , question or feedback about the article let it out here!