Line 27: Line 27:
  
 
=Code=
 
=Code=
==Beep==
+
==Buzzer Beep==
 +
Turn ON and OFF the buzzer with a delay of 1sec.
 +
<html>
 +
<script src="https://gist.github.com/SaheblalBagwan/f0bd96ce77327ea39989.js"></script>
 +
</html>
  
 
=Wiring diagram=
 
=Wiring diagram=

Revision as of 17:11, 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

Buzzer Beep

Turn ON and OFF the buzzer with a delay of 1sec.

#include <avr/io.h>
#include <util/delay.h>
int main()
{
DDRC = 0xff; // Configure PORTC as output
while(1)
{
PORTC = 0xff; // Turn ON the Buzzer conneted to PORTC
_delay_ms(1000); // Wait for some time
PORTC = 0x00; // Turn OFF the Buzzer connected to PORTC
_delay_ms(1000); // Wait for some time
}
return 0;
}

Wiring diagram


Video Tutorial