단일 컴퓨터 인스턴스 - I LOVE U

1993 단어
#include
#include

typedef unsigned int u16;
typedef unsigned char u8;

sbit butt = P3^2;  //    ,       0

sbit RCLK = P3^5;
sbit SRCLK = P3^6;
sbit SER = P3^4;  //HC595  

u8 code led_H[] = {0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};//    
u8 code ledL_I[] = {0x00,0x81,0x81,0xff,0xff,0x81,0x81,0x00}; //I     
u8 code ledL_LOVE[] = {0x30,0x78,0xfe,0x7f,0x7f,0xfe,0x78,0x30};//     
u8 code ledL_U[] = {0x00,0xff,0xff,0x03,0x03,0xff,0xff,0x00};    //U   

u8 flag=0;//       flag = 0;


void delay(u16 i)   //    
{
    while(i--);
}

void HC595(u8 dat)  //HC595  
{
    u8 a;
    RCLK = 0;
    SRCLK = 0;         
    for(a=0;a<8;a++){
        SER = dat>>7;
        dat <<= 1;
        SRCLK = 1;
        _nop_();
        _nop_();
        SRCLK = 0;      
    }
    RCLK = 1;
    _nop_();
    _nop_();
    RCLK = 0;
}

void Int0_init() //       0      
{
    EA = 1;
    IT0 = 1;
    EX0 = 1;
}

void main() //   
{   
    Int0_init();
    while(1){
        u8 j;
        switch(flag){  //switch  
              case 0:for(j=0;j<8;j++){
                       HC595(ledL_I[j]);
                       P0 = led_H[j];
                       delay(100);
                       HC595(0x00);
                       };break;
              case 1:for(j=0;j<8;j++){
                        HC595(ledL_LOVE[j]);
                        P0 = led_H[j];
                        delay(100);
                        HC595(0x00);
                        };break;
              case 2:for(j=0;j<8;j++){
                        HC595(ledL_U[j]);
                        P0 = led_H[j];
                        delay(100);
                        HC595(0x00);
                        };break;
        }
    }
}

void INT() interrupt 0
{   
    if(butt==0){
        delay(1000);
        if(butt==0){//    
            if(flag<2) flag++;
            else flag=0;
        
        }
    }
}

//  :I LOVE U(           )  

좋은 웹페이지 즐겨찾기