#include "reg52.h" #include <intrins.h>void delay (int i) {while (i--);} void Main () {char i;led=0xfe;delay (50000), while (1) {i=0;i<7;i++) {P2=_crol_ (p2,1);d Elay (50000);} for (i=0;i<7;i++) {p2=_crled_ (p2,1);d Elay (50000);}}
1#include"reg52.h" 2Sbit lsa=p2^2;3Sbit lsb=p2^3;4Sbit lsc=p2^4;5U8 Code smgduan[ -]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,6 0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};//displays the value of the 0~f7 voidDelayinti)8 {9 while(i--); Ten } One voidDigdisplay () A { - Chari; - for(i=0;i<8; i++) the { - Switch(i)//selection, select the light-lit digital tube, - { - Case(0): +Lsa=0; lsb=0; Lsc=0; Break;//Show No. 0 bit - Case(1): +Lsa=1; lsb=0; Lsc=0; Break;//Show 1th bit A Case(2): atLsa=0; lsb=1; Lsc=0; Break;//Show 2nd Bit - Case(3): -Lsa=1; lsb=1; Lsc=0; Break;//Show 3rd Bit - Case(4): -Lsa=0; lsb=0; Lsc=1; Break;//Show 4th Bit - Case(5): inLsa=1; lsb=0; Lsc=1; Break;//Show 5th Bit - Case(6): toLsa=0; lsb=1; Lsc=1; Break;//Show 6th Bit + Case(7): -Lsa=1; lsb=1; Lsc=1; Break;//Show 7th Bit the } *P0=smgduan[i];//Send segment Code $Delay -);//interval Time ScanPanax Notoginsengp0=0x00;//blanking - } the } + A voidMain () the { + while(1) - { $Digdisplay ();//Digital Tube Display function $ } -}
LED running light Dynamic Digital Tube 52 single chip microcomputer