Line 76: Line 76:
 
=Code=
 
=Code=
 
<syntaxhighlight>
 
<syntaxhighlight>
 +
/*-----------------------------------------------------------------------------
 +
                Program to demonstrate Buzzer
 +
  -----------------------------------------------------------------------------
 +
 +
note: Connect Buzzer on PORTB.0
  
 +
------------------------------------------------------------------------------*/
 +
 +
 +
/* htc.h contains the definition of all ports and SFRs */
 +
#include <avr\io.h>
 +
#include "stdutils.h"
 +
#include "delay.h" //User defined library which contains the delay routine
 +
 +
/* start the main program */
 +
void main()
 +
{
 +
  /*Configure PORTB.0 port as output */
 +
 
 +
  DDRB= 0x01;
 +
 
 +
 +
  while(1)
 +
    {
 +
 +
/* Turn On buzzer and wait for 3 second */
 +
 
 +
  PORTB = 0x01;
 +
 
 +
  DELAY_sec(3);
 +
 
 +
  /* Turn Off buzzer and wait for 3 second */
 +
 
 +
  PORTB = 0x00;
 +
 
 +
  DELAY_sec(3);
 +
 +
 +
  }
 +
  }
  
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
=Video Tutorial=
 
=Video Tutorial=
For those of you, who would like to watch instead of read we have made a video with all the gyan.
 
<br>
 
{{#ev:youtubehd|-lNAmSNV2-Q|640}}
 

Revision as of 14:11, 18 November 2015

Guru (talk) 20:00, 17 November 2015 (IST)


The Rock (1996)


Hookup

You may look this up with the simple breadboard as shown in section below or you could use the Ultra AVR dev kit if do not wish to jumble with wires and resistors.

Type 1:Breadboard with Explore AVR 40 Pin Breakout Board with Atmega32

Components Used

1

AVR 40 pin breakout board with Atmega32

Click here to buy from our store

2

Breadboard

Click here to buy from our store

3

Male to Male Jumper Wires

Click here to buy from our store

4

Transistor - BC547

[ Click here to buy from our store]

5

Buzzer

[ Click here to buy from our store]

6

Resistor

Click here to buy from our store

Wiring diagram

Type 2:Using Explore Ultra AVR Dev Kit

Components Used

The Explore Ultra AVR Kit comes with all the things required, not just for this experiment but for the entire series. And even if you think of migrating to PIC or Arduino, you'll have breakout boards that fit on to this, hence we believe it is a great investment for learning hands on Embedded Systems. The kit is fully open source, you may use the schematics, the design files and all of the source code and build something cool on your own. And when you do that do not forget to share with us what you've done. We would be happy to see you building something cool.


Code

 /*-----------------------------------------------------------------------------
                 Program to demonstrate Buzzer
  -----------------------------------------------------------------------------
 
note: Connect Buzzer on PORTB.0
 
------------------------------------------------------------------------------*/
 
 
/* htc.h contains the definition of all ports and SFRs */
#include <avr\io.h>
#include "stdutils.h"
#include "delay.h" //User defined library which contains the delay routine
 
/* start the main program */
void main() 
{
  /*Configure PORTB.0 port as output */
 
   DDRB= 0x01;
 
 
  while(1)
    {
 
	 /* Turn On buzzer and wait for 3 second */ 
 
	   PORTB = 0x01;
 
	   DELAY_sec(3);
 
	  /* Turn Off buzzer and wait for 3 second */ 
 
	   PORTB = 0x00;
 
	   DELAY_sec(3);
 
 
		  }
  }

Video Tutorial