This ckt explains about the ckt configuration. This ckt in which led blink will glow for 5 sec and remain off for another 5 sec.
The embedded C code for atmega 8 is as follows....
#define F_CPU 1000000UL // define the working frequency of atmega 8
#include <avr/io.h> // include avr files
#include <util/delay.h> // include header file for delay
//Function that defines the delay
//delayms(1000) - 1 sec delay
void delayms(uint16_t millis) {
while ( millis ) {
_delay_ms(1);
millis--;
}
}
// main program starts from here
int main(void) {
DDRC = 0xFF; // defines that C pORT will act as o/P port.
// if DDRC=0x00 ,then PORT C will act as I/P port.
PORTC=0x00; // initial declaration of PORT C
while(1) {
PORTC = 0x00;
delayms(5000); // delay for 5 sec
PORTC = 0xFF;
delayms(5000);
}
return 0;
}
The embedded C code for atmega 8 is as follows....
#define F_CPU 1000000UL // define the working frequency of atmega 8
#include <avr/io.h> // include avr files
#include <util/delay.h> // include header file for delay
//Function that defines the delay
//delayms(1000) - 1 sec delay
void delayms(uint16_t millis) {
while ( millis ) {
_delay_ms(1);
millis--;
}
}
// main program starts from here
int main(void) {
DDRC = 0xFF; // defines that C pORT will act as o/P port.
// if DDRC=0x00 ,then PORT C will act as I/P port.
PORTC=0x00; // initial declaration of PORT C
while(1) {
PORTC = 0x00;
delayms(5000); // delay for 5 sec
PORTC = 0xFF;
delayms(5000);
}
return 0;
}
No comments:
Post a Comment