Scroll lottery system --- difficult for me Dian

keil development board implements a rolling lottery system

Code has been given, copy the code and paste it into keilc51 the project, click the Compile button to generate .hex file, open the generated circuit diagram Select .hex file before running, clicking on the left button 1 button on the right LED stop, digital display, click LED digital rotation again, click on the digital display digital digital stop again. (Software files, installation method, create a project, there is the circuit diagram in front of me in the blog)

#include <reg52.h> 
#define LED_ALL P0
sbit KEY1 = P1^0;
unsigned char LED_NUM[] = {0x3f,0x06,0x5b,0x4f,\
                           0x66,0x6d,0x7d,0x07,\
                           0x7f,0x6f};
void main()
{
        unsigned char i;
        unsigned char flag = 0;
    while(1)
    {    
            if(flag == 0)
            {
                for(i=0;i<10;i++)
                {
                    if(KEY1 == 0)
                    {
                        flag = ~flag;
                        while(KEY1 == 0);
                        break;
                    }
                    LED_ALL = LED_NUM[i];                
                }
            }
        if(KEY1 == 0)
        {
            flag = ~flag;
            while(KEY1 == 0);
        }    
    }
}

                   

 

                    

 

 Like you can point a concern, thank you ~

 

Guess you like

Origin www.cnblogs.com/LeiZL/p/11721996.html