Line 23: Line 23:
 
</html>
 
</html>
  
==Wiring diagram==
+
 
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/fritzing-tutorials_de69ccc2/buzzer_bb.png" width="670 px"></html>
+
  
  
 
=Code=
 
=Code=
<syntaxhighlight>
 
/*-----------------------------------------------------------------------------
 
                Program to demonstrate Buzzer
 
  -----------------------------------------------------------------------------
 
 
note: Connect Buzzer on PORTB.0
 
  
------------------------------------------------------------------------------*/
+
=Wiring diagram=
 
+
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/fritzing-tutorials_de69ccc2/buzzer_bb.png" width="670 px"></html>
 
+
/* 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>
 
  
 
=Video Tutorial=
 
=Video Tutorial=

Revision as of 16:30, 4 February 2016

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


The Rock (1996)


Objective

After blinking the leds and Controlling tnem with switches, its time to make some noise using the buzzer. In the first part of the tutorial, we will beep the buzzer every 2secs. At the end we will control the buzzer using a switch.

Register Configuration

Please refer the below tutorial for basics of GPIO register configuration.



Code

Wiring diagram


Video Tutorial