sang dan 2 lan, tat dan 3lan 8 led portB

// sang dan 2 lan, tat dan 3lan 8 led portB

#include "16f877a.h"

#include "def_877a.h"

#use delay(clock=4mhz)

char i,j,k,n;

void main()

{

trisb=0;

while(true)

{

/*tat dan 3 lan cac led*/

for(n=1;n<=3;n++)

{

portb=0x00;

k=0x00;

delay_ms(50);

j=0b00000001;

for(i=1;i<=8;i++)

{

k=k|j;

portb=k;

delay_ms(50);

j<<=1;

}

}

/*sang dan 2 lan cac led*/

for(n=1;n<=2;n++)

{

portb=0xff;

k=0xff;

delay_ms(50);

j=0b11111110;

for(i=1;i<=8;i++)

{

k=k&j;

portb=k;

delay_ms(50);

j<<=1;

}

}

}

}

Bạn đang đọc truyện trên: AzTruyen.Top

Tags: