51 single-chip microcomputer digital tube display and decoder

Source: Internet
Author: User

Common Anode Array 0~9:display[]={0xc0,0xf9,0xa4,0xb0,0x91,0xa2,0x82,0xf8,0x80,0x90}

Common Anode Array a~f:display[]={0x88,0x83,0xa6,0xc1,0x86,0x8e}

Common cathode Array 0~9:display[]={0x3f,0x06,0x5b,0x4f,0x6e,0x6d,0x7d,0x07,0x7f,0x6f}

Common cathode Array a~f:display[]={0x77,0x7c,0x59,0x3e,0x79,0x71}

Common Yin, two groups of four-in-one digital tube, bit selection 74ls138 decoder, input (bit selection) CBA p20,p21,p22. De Shun through 74573 followed by P1 port.

If the decoder is not used, the bit selection can be directly connected to the IO port, and the assignment value is changed.

1 /*******************************************************************************2 * Experimental Name: Dynamic Digital Tube Display3 * Experimental Description: 8-digit digital tube display in turn 0~74 * Author: L25 * Time: 2016-08-026 7 *******************************************************************************/8#include <reg51.h>9 Ten #defineGpio_dig P1//Digitron Digital Tube OneSbit lsa= p2^0; ASbit lsb= p2^1; -Sbit lsc= p2^2; -  theUnsignedCharCode dig_code[Ten]={ - 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//Display code for 0~9 - voidDigdisplay (); -  + voidMainvoid) - { +      while(1) A Digdisplay ();  at } -  -  - voidDigdisplay () - { -UnsignedChari; inUnsignedintJ; -      for(i=0;i<8; i++) to     { +         Switch(i)//selection, select the light-lit digital tube, -         { the              Case(0): *Lsa=0; lsb=0; Lsc=0; Break;//Show No. 0 bit $              Case(1):Panax NotoginsengLsa=1; lsb=0; Lsc=0; Break;//Show 1th bit -              Case(2): theLsa=0; lsb=1; Lsc=0; Break;//Show 2nd Bit +              Case(3): ALsa=1; lsb=1; Lsc=0; Break;//Show 3rd Bit the              Case(4): +Lsa=0; lsb=0; Lsc=1; Break;//Show 4th Bit -              Case(5): $Lsa=1; lsb=0; Lsc=1; Break;//Show 5th Bit $              Case(6): -Lsa=0; lsb=1; Lsc=1; Break;//Show 6th Bit -              Case(7): theLsa=1; lsb=1; Lsc=1; Break;//Show 7th Bit -         }WuyiGpio_dig=dig_code[i];//Send segment Code thej=10000;//Scan interval Time setting, if J is reduced, stable display of 0~7 can be observed (scanning speed is too fast for human eyes to recognize) -          while(j--);  Wugpio_dig=0x00;//blanking -     } About}

1 /*******************************************************************************2 * Experimental Name: Digital Tube Stopwatch Display3 * Experiment Description: 0~59 display in turn4 * Author: L25 * Time: 2016-08-036 7 *******************************************************************************/8#include <reg51.h>9 Ten #defineGpio_dig P1//Digitron Digital Tube One #defineUchar unsigned char A #defineUINT unsigned int -Sbit lsa= p2^0; -Sbit lsb= p2^1; theSbit lsc= p2^2; -  -Uchar shi,ge,num1=0, num=0; -Uchar Code dig_code[Ten]={ + 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//Display code for 0~9 - voiddelay5ms (); + voiddigdisplay (Uchar shi,uchar ge); A  at  - voidMain () -{//200 μs @20mhz -Tmod =0x01;//Set Timer mode -TL0 =0xa8;//Set the timing initial value -TH0 =0xFD;//Set the timing initial value inEA =1;//Open Total Interrupt -TF0 =0;//clear the TF0 flag toET0 =1;//Open Timer 0 Interrupt +TR0 =1;//Timer 0 Start Timer -      while(1) the     { * Digdisplay (shi,ge); $     }Panax Notoginseng } -  the voiddigdisplay (Uchar shi,uchar ge) + { AGpio_dig=dig_code[shi];//Segment Selection theLsa=0; lsb=0; Lsc=0;  + delay5ms (); -gpio_dig=Dig_code[ge];  $Lsa=1; lsb=0; Lsc=0; $ delay5ms ();  - } -  the voidTimer0init (void) Interrupt1 - {WuyiTL0 =0xa8;//re-install the initial theTH0 =0xFD; -num1++; Wu     if(num1== $)//5 times 200ms is 1s to -     { Aboutnum1=0; $num++; -          if(num== -) -num=0; -shi=num/Ten; AGE = num%Ten; +     }     the } -  $  the voidDELAY5MS ()//@12.000mhz the { theUnsignedCharI, J; the  -i = -; inj = -; the      Do the     { About          while(--j); the} while(--i); the}

51 single-chip microcomputer digital tube display and decoder

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.