Scroll lottery system ---- 10969

First, the required software and circuit diagrams, use, operation method, see my previous blog post.

 

Second, the code is required.

(1) using a digital scroll numbers 1-9

(2) using the control button 1

(3) When the button is pressed to stop scrolling digital numbers, the digital display is a digital to digital lottery.

 

Third, start

1, the total open keil_proteus circuit diagram, as shown below.

 

 2, open Keil uVision4 start writing code, you need to create 51 single project details, see my The second blog post.

 

 

code show as below.

#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);
        }    
    }
}

3, finally will generate hex file added to the total keil_proteus circuit diagram can be run, "adding," The second I look at the specific operation Bowen.

Guess you like

Origin www.cnblogs.com/dyw31/p/11722016.html