Difference between revisions of "Controlling AC devices with AVR using Relays"
Raghavendra (Talk | contribs) |
Raghavendra (Talk | contribs) |
||
Line 16: | Line 16: | ||
=Code= | =Code= | ||
− | The code turns ON and OFF the relays, every 5 seconds. | + | The code turns ON and OFF the relays, every 5 seconds. |
+ | |||
+ | <html> | ||
+ | <script src="https://gist.github.com/raghavendrahassy/590b58d9204da2c7323c.js"></script> | ||
+ | </html> | ||
=Demo= | =Demo= | ||
[[File:0Lightbulb.gif#sthash.z7CJwlOp.dpuf|none]] | [[File:0Lightbulb.gif#sthash.z7CJwlOp.dpuf|none]] |
Revision as of 10:24, 29 March 2016
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.
Code
The code turns ON and OFF the relays, every 5 seconds.