pemrograman led geser dengan codevision….

image

#include <mega8535.h>
#include <delay.h>

// Declare your global variables here

void main(void)
{
// Declare your local variables here
unsigned char data,in;

PORTC=0x00;
DDRC=0xff;
PORTD=0x00;
DDRD=0x00;
data=0;
PORTC=data;

while (1)
{
// Place your code here
PORTC=data;
in=PIND;
delay_ms(100);
if(((in&0x01)==0)&&(data!=128)&&(data!=0))data=data*2;
else if(((in&0x01)==0)&&(data==128)&&(data!=0))data=1;
if(((in&0x01)==0)&&(data==0))data=1;

if(((in&0x02)==0)&&(data!=1)&&(data!=0))data=data/2;
else if(((in&0x02)==0)&&(data==1)&&(data!=0))data=128;
if(((in&0x02)==0)&&(data==0))data=128;
};
}

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: