What is the function we want to achieve?
From the first digital tube scanning 1 to the second digital Tube 2, a third digital tube 3, .... Until the 8th Digital tube Display 8
1 /*--------------www.szjcdz.cn--------------------2 Name: Digital Tube Dynamic Scan3 written by: Shenhui4 Date: 2015.10.285 content: Digital tube Dynamic Scanning6 ------------------------------------------------*/7#include <reg52.h>8 #defineUchar8 unsigned char9 #defineuint16 unsigned intTenSbit latch1=p2^6; OneSbit latch2=p2^7; A voiddisplay (); - -UCHAR8 Code duanma[]={0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80};//Show segment code value 0~F theUCHAR8 Code weima[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};//corresponding to the corresponding digital tube lit, the accession code - -Uchar8 Template;//Global variables that store display values - + //Delay Function - voiddelayms (uint16 val) + { A uint16 i,j; at for(i=0; i<val;i++) - for(j=0;j<113; j + +); - - } - - in //******************************* main function *******************************// - voidMainvoid) to { + Panax Notoginseng - the display (); + A the + - } $ $ - - voidDisplayvoid ) the { - uint16 i;Wuyi while(1) the { - Wu for(i=0;i<8; i++) - { Aboutp0=0; $latch1=1; -latch1=0; - - Ap0=weima[7-i]; +Latch2=1; theLatch2=0; - $ thep0=Duanma[i]; thelatch1=1; thelatch1=0; the -Delayms ( $); in the } the About } the the the}
Re-picking the second day of the use of digital tube (dynamic scanning digital tube)