Tuesday, 6 December 2011

PROGRAM GESER LED PADA PPI 8255



/*PROGRAM GESER LED PADA PPI 8255*/
#include
#include
#include
void delay()
{
int j,k;
for (j=0; j<=30000;j++)
{
for(k=0; k<30000;k++)
{
k = k+1;
}
j=j+1;
}
}


void menu(void);
void geserkiri ();
void geserkanan ();
main ()

int pilih;

do{
outportb(0x303,0x80);
outportb(0x300,0x00);
clrscr();
menu();
scanf("%d",&pilih);
switch(pilih) {
case 1: geserkiri ();break;
case 2: geserkanan ();break;

case 3:
printf("Terima kasih\n\n");break;
default:
printf("Pilihan salah\n");
}
continue; }
while(pilih<=2||pilih>=4);
}

void menu() {


printf("MENU\n");
printf("1. led geser kiri \n");
printf("2. led geser kanan \n");
printf("3. keluar\n");
printf("pilih menu : ");

}

void geserkiri ()
{ int data,i;
outportb(0x303,0x80);

/*port A*/
data = 0x01;
for (i= 1;i<= 8; i++)
{
printf("Data LED = %x\n",data);
outportb(0x300,data);
delay();
data=data << 1;
}
outportb(0x300,0x00);
}

void geserkanan()
{
int data2,ii;
outportb(0x303,0x80);
/*port A*/
data2 = 0x80;
for (ii= 1;ii<= 8; ii++)
{
printf("Data LED = %x\n",data2);
outportb(0x300,data2);
delay();
data2=data2 >> 1;
}
outportb(0x300,0x00);
}
MAU DATA LENGKAP ::
fb/email: ekosaputro21@yahoo.co.id



No comments:

Post a Comment