#include<reg51.h> #define uchar unsigned char #define uint unsigned int uchar code TAB[]={0X81,0XBF,0XBF,0X81,0XFD,0XFD,0XFD,0X81, 0X81,0XBF,0XBF,0X81,0XBF,0XBF,0XBF,0X81, 0XDD,0XDD,0XDD,0X81,0XDF,0XDF,0XDF,0XDF, 0X81,0xFD,0xFD,0x81,0xBF,0xBF,0xBD,0xC3}; uchar i,t; delay(uchar t) { while(t--) {;} } void main(void) {uchar N,T; while(1) { for(N=0;N<4;N++) for(T=0;T<200;T++) { P2=0XFE; for(i=0;i<8;i++) { P1=TAB[i+8*N]|P0; delay(100); P2=(P2<<1)|(P2>>7); } } } } 上面的程序当LED亮的时候是红色,下面的是绿色 #include<reg51.h> #define uchar unsigned char #define uint unsigned int uchar code TAB[]={0X81,0XBF,0XBF,0X81,0XFD,0XFD,0XFD,0X81, 0X81,0XBF,0XBF,0X81,0XBF,0XBF,0XBF,0X81, 0XDD,0XDD,0XDD,0X81,0XDF,0XDF,0XDF,0XDF, 0X81,0xFD,0xFD,0x81,0xBF,0xBF,0xBD,0xC3}; uchar i,t; delay(uchar t) { while(t--) {;} } void main(void) {uchar N,T; while(1) { for(N=0;N<4;N++) for(T=0;T<200;T++) { P2=0XFE; for(i=0;i<8;i++) { P0=TAB[i+8*N]|P0; delay(100); P2=(P2<<1)|(P2>>7); } } } } 请问如何能这个程序合并在一起呢,呈现黄色呢? 如何要出现三种情况这个程序该如何写的? |