Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <util/delay.h>
- // Macro
- #define BEEPON 127
- #define BEEPOFF 0
- #define TRUE 1
- #define FALSE 0
- #define STDBEEP OCR0A = BEEPON; _delay_ms(500); OCR0A=BEEPOFF;
- static void init(void);
- int main(void)
- {
- init();
- int done = FALSE;
- while(1)
- {
- if(PINB & 0x02)
- {
- while (!done)
- {
- STDBEEP;
- _delay_ms(1000);
- STDBEEP;
- _delay_ms(750);
- STDBEEP;
- _delay_ms(500);
- STDBEEP;
- _delay_ms(250);
- STDBEEP;
- _delay_ms(100);
- STDBEEP;
- _delay_ms(100);
- STDBEEP;
- _delay_ms(50);
- STDBEEP;
- _delay_ms(25);
- // Last beep
- OCR0A = BEEPON;
- _delay_ms(1000);
- OCR0A = BEEPOFF;
- done = TRUE;
- }
- }
- }
- return 1;
- }
- static void init(void)
- {
- // Data Direction
- // PB1(Pin 6): PWM Output
- // PB2(Pin 7): Button Input
- DDRB = 0x01;
- //PINB = 0x02;
- PORTB = 0x00;
- // PWM Setup
- TCCR0A = 0x82;
- TCCR0B = 0x02;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement