Running Led sample code using ATMega8 [Compiler Using CodeVisionAVR]

Posted on June 2, 2011. Filed under: ---ALL---, Hardware, Teknologi Informasi | Tags: , , , , |

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);
}

Advertisement

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Liked it here?
Why not try sites on the blogroll...

Follow

Get every new post delivered to your Inbox.