Advertisement
avr_programmieren_rh

Blink Arduino DIGITAL PIN 13 (LED).c

Feb 25th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.87 KB | None | 0 0
  1. /*
  2.  * Blink Arduino DIGITAL PIN 13 (LED).c
  3.  *
  4.  * Created: 04.12.17 11:24:32
  5.  * Author : Hiestermann
  6.  */
  7. #ifndef F_CPU                                                   // Hier wird abgefragt ob F_CPU schon definiert ist
  8. #define F_CPU 18432000                                          // wenn F_CPU noch nicht definiert war, wird es hier mit 18,432MHz nachgeholt
  9. #warning "F_CPU war nicht definiert, wurde jetzt nachgeholt"    // und zusätzlich eine Warnung ausgegeben
  10. #endif
  11.  
  12. #include <avr/io.h>
  13. #include <util/delay.h>
  14.  
  15. int main(void)
  16. {  
  17.     DDRB=0xFF;          //Setzte Port B auf Ausgang
  18.     PORTB=0b0000000;    //Setze PORTB auf low
  19.     while (1)
  20.     {      
  21.         PORTB |= (1 << PORTB5);     // Arduino DIGITAL PIN 13 (LED) auf HIGH
  22.         _delay_ms(500);             // 500ms Warten
  23.         PORTB &= (0 << PORTB5);     // Arduino DIGITAL PIN 13 (LED) auf LOW
  24.         _delay_ms(500);             // 500ms Warten
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement