A technology based on 51 microcontroller and using 74HC595 to drive digital tubes

Publisher:JoyfulHeartedLatest update time:2023-08-16 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Based on the 51 microcontroller, the eight digital tube patterns are displayed as follows:

xxx11xxx→xx2222xx→x333333x→44444444→x555555x→xx6666xx→x777777x→88888888


Each state lasts one second, and the display cycles repeatedly, where x indicates that the corresponding digital tube is off.

Supplement to the question: It is a digital tube with a common anode, driven by a 595 chip. Using C language.

================================================== =

Best answer: The program design is completed, and the screenshots of PROTEUS simulation are as follows.

A technology based on 51 microcontroller and using 74HC595 to drive digital tubes

The procedure is as follows:

//==============================================

#include

#define uint unsigned int

#define uchar unsigned char

//HC595 chip

sbit H_ds = P2^0;

sbit H_shcp = P2^1;

sbit H_stcp = P2^2;

char code DISP_8[] = {

0x00, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f};

char code TAB_64[] = {

0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0,

0, 3, 3, 3, 3, 3, 3, 0, 4, 4, 4, 4, 4, 4, 4, 4,

0, 5, 5, 5, 5, 5, 5, 0, 0, 0, 6, 6, 6, 6, 0, 0,

0, 7, 7, 7, 7, 7, 7, 0, 8, 8, 8, 8, 8, 8, 8, 8};

char i = 1, j = 0;

char DISP_B[] = {0, 0, 0, 0, 0, 0, 0, 0};

//------------------------------------------------ ------------------

void sendbyte_H (uchar aa) //Use HC595 output

{

char z;

aa = ~aa;

for (z = 0; z < 8; z++) { //Loop 8 times to move in data

H_shcp = 0;

H_ds = aa & 128; //The data bits are sent to the HC595 data line

H_shcp = 1; //Input data on rising edge

aa "《= 1;

}

}

//------------------------------------------------ ------------------

void display()

{

char z;

for (z = 0; z < 8; z++) DISP_B[z] = TAB_64[j * 8 + z];

j++; j %= 8;

for (z = 0; z < 8; z++) sendbyte_H (DISP_8 [DISP_B [z]]);

H_stcp = 0; H_stcp = 1; //The rising edge causes data to be output in parallel

}

//------------------------------------------------ ------------------

void main()

{

TMOD = 0x01;

TH0 = (65536 - 46080) / 256; //50ms@11.0592MHz

TL0 = (65536 - 46080) % 256;

TR0 = 1;

ET0 = 1;

EA = 1;

while(1);

}

//------------------------------------------------ ------------------

void T0_time()interrupt 1

{

TL0 = (65536 - 46080) % 256; //Reset initial value

TH0 = (65536 - 46080) / 256; //50ms@11.0592MHz

i--;

if (i == 0) {

i = 40;

display(); //pattern display

}

}

//------------------------------------------------ ------------------


Reference address:A technology based on 51 microcontroller and using 74HC595 to drive digital tubes

Previous article:Production of 51 microcontroller "building block" experimental board
Next article:Implementation method of communication between 51 microcontroller and computer

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号