Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. /* ------------------------------------------------------------
  2.   Titel : Projekt Rauchmelder
  3.  --------------------------------------------------------------
  4.  Funktion :  Zähler & Tasterentprellung
  5.  --------------------------------------------------------------
  6.  Prozessor : ATmega8
  7.  Taktfrequenz externer Quarz:    3,686411 MHz
  8.  Sprache : C
  9.  Datum : ©2010
  10.  Version : 1.1
  11.  ------------------------------------------------------------ */
  12.  
  13. #include <avr/io.h>
  14. #include <util/delay.h>
  15. #include <avr/interrupt.h>
  16.  
  17.  ISR (ANA_COMP_vect)                                 // Interrupt 0 Sub-Routine (ISR)
  18.     {
  19.     PORTB  |= 0x04;
  20.     while(bit_is_set (PINB,2))
  21.     {
  22.     PORTB = 0x02;
  23.      /*for(int x=0;x<=500;x++)
  24.      {
  25.      PORTB |= 0x02;
  26.      _delay_ms(2.5);
  27.      PORTB &=~ 0x02;
  28.      _delay_ms(2.5);
  29.      }
  30.      _delay_ms (200);
  31.      for(int y=0;y<=500;y++)
  32.      {
  33.      PORTB |= 0x02;
  34.      _delay_ms(3);
  35.      PORTB &=~ 0x02;
  36.      _delay_ms(3);
  37.      }
  38.      */
  39.      }
  40.    
  41.    
  42.     }
  43.  
  44. void main (void)
  45. {
  46.   DDRB  = 0x03;
  47.   PORTB = 0x04;
  48.   PORTC = 0x00;
  49.   DDRC  = 0x00;
  50.   PORTD = 0x00;
  51.   DDRD  = 0x00;
  52.   ACSR  = 0x0b; // Analog Comparator Status Register
  53.   SFIOR = 0x08; // Multiplexer
  54.  
  55.     while (1)
  56.     {
  57.       PORTB = 0x01;
  58.       _delay_ms(2500);
  59.       PORTB = 0x00;
  60.       _delay_ms(6000);
  61.      
  62.       sei ();
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement