Advertisement
KgCro

L07Z01_2

Nov 26th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1.  
  2. #define F_CPU 7372800UL // UL -> unsigned long - frekvencija CPU-a
  3.  
  4. #include <avr/io.h>
  5. #include <util/delay.h>
  6.  
  7. void delaying(uint16_t timeout){
  8.     uint16_t i;
  9.     for (i=0;i<timeout;i++){
  10.         _delay_ms(1);
  11.     }
  12. }
  13.  
  14. void blink(void){
  15.     PORTA ^= _BV(5); // _BV -> bitvise
  16. }
  17.  
  18. int main(void)
  19. {
  20.     DDRA = _BV(5);
  21.     PORTA = _BV(5);
  22.    
  23.     uint16_t timeout = 100;
  24.    
  25.     while (1) {
  26.         blink();
  27.         timeout = timeout + 100;
  28.         delaying(timeout);
  29.         //_delay_ms(100); // 100ms delay -> half cycle , 200ms -> full cycle
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement