Created
March 16, 2015 12:34
-
-
Save goFrendiAsgard/f37908a535fd575a0003 to your computer and use it in GitHub Desktop.
Blinking atmega
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* ledblink.c, an LED blinking program */ | |
| #define F_CPU 1000000UL | |
| #include<avr/io.h> | |
| #include<util/delay.h> | |
| void sleep(uint8_t millisec) | |
| { | |
| while(millisec) | |
| { | |
| _delay_ms(1);/* 1 ms delay */ | |
| millisec--; | |
| } | |
| } | |
| void main() | |
| { | |
| DDRB |=1<<PB0; /* PB0 will now be the output pin */ | |
| // DDRB = DDRB | 1<<PB0; | |
| // DDRB = 0xb00000001; | |
| while(1) | |
| { | |
| PORTB &= ~(1<<PB0);/* PB0 LOW */ | |
| // PORTB = 0xb00000001; | |
| sleep(1000);/* 100 ms delay */ | |
| PORTB |=(1<<PB0); /* PB0 HIGH */ | |
| // PORTB = 0xb00000000; | |
| sleep(1000);/* 100 ms delay */ | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment