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 OCR1B = BEEPON; _delay_ms(500); OCR1B=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
- OCR1B = BEEPON;
- _delay_ms(1000);
- OCR1B = 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
- //TCCR1 = 0x58;
- //PLLCSR = 0x82;
- //GTCCR = 0x00;
- //PLLCSR |= 0x01;
- TCCR0A = _BV(WGM00) | _BV(COM0A1) | _BV(COM0B1);
- TCCR0B |= _BV(CS01);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement