• 数码管动态显示——锁存器


    1、电路设计:

     LE接P3.0来实现段选或位选,OE接地,当LE为高电平的时候,锁存器为通路。

    2、程序设计:

    #include<reg52.h>
    sbit P3_0 = P3^0;
    code unsigned char seven_seg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf,0xff};     
    void delay(unsigned int x){
        while(x--);
    }
    int main(){
        while(1){
          P3_0 = 0;P0 = 0x01;P3_0 = 1;P3_0 = 0;P0 = seven_seg[0];delay(150);P0=0xff;
            P3_0 = 0;P0 = 0x02;P3_0 = 1;P3_0 = 0;P0 = seven_seg[1];delay(150);P0=0xff;        
            P3_0 = 0;P0 = 0x04;P3_0 = 1;P3_0 = 0;P0 = seven_seg[2];delay(150);P0=0xff;    
            P3_0 = 0;P0 = 0x08;P3_0 = 1;P3_0 = 0;P0 = seven_seg[3];delay(150);P0=0xff;    
            P3_0 = 0;P0 = 0x10;P3_0 = 1;P3_0 = 0;P0 = seven_seg[4];delay(150);P0=0xff;        
            P3_0 = 0;P0 = 0x20;P3_0 = 1;P3_0 = 0;P0 = seven_seg[5];delay(150);P0=0xff;
            P3_0 = 0;P0 = 0x40;P3_0 = 1;P3_0 = 0;P0 = seven_seg[6];delay(150);P0=0xff;        
            P3_0 = 0;P0 = 0x80;P3_0 = 1;P3_0 = 0;P0 = seven_seg[7];delay(150);P0=0xff;
        }
    }

    3、运行结果:

     以前需要两个端口来实现的显示功能,现在只需要一个P0口就可以实现数码管的显示,大大减少了端口的占用,电路的设计更加合理。

  • 相关阅读:
    一个完成的spring xml配置文件
    一个简单的Spring程序
    Spring beans.xml
    strust2的核心和工作原理
    MVC模式
    JSON 之FastJson解析
    Java本地方法(native方法)的实现
    RMI(Remote Method Invocation ) 概念恢复
    java注解
    输入sql语句,将结果写入到xml文件
  • 原文地址:https://www.cnblogs.com/zhai1997/p/11623650.html
Copyright © 2020-2023  润新知