Running Led sample code using ATMega8 [Compiler Using CodeVisionAVR]
The list below introducing running led sample c code for Atmel ATMega8 uC. Using CodeVisionAVR as compiler. If you’re using AVR Studio feel free to change the code especially @ include and other diffrent parameter.
/*running led
4 output using Port D.1 .. D.4
hardware installation:
i/o pin[PD.1] — Resistor 470 ohm — Led Catode/ Led Anode –Vcc(+5)
original version of CKJ Industries
sample using CodeVisionAVR for other compiler check it out about #include and other support listing code
Chip: ATMega8
Memory Model: ATMega
Data Stack Size: 64 bytes
*/
#include <mega8.h>
#include <delay.h>
//start code here
int main(){
unsigned char i,j;
DDRD = 0x1E; //Using PD.1 .. PD.4
while (1) {
j=16;
for(i=0;i<5;i++){
PORTD=j;
delay_ms(500);
j=j/2;
};
};
return(1);
}


