PROTEUS simulation diagram
/****************led digital tube header file************************/
#ifndef __led_H__
#define __led_H__
#define led_wei_ddr DDRD|=0X0F
#define led_wei PORTD
#define led_duan_ddr DDRF=0XFF
#define led_duan PORTF
extern void led_display(uint dat,uchar num);
#endif
/************C file of led digital tube display function************/
#include "config.h"
//With 0x7f above, there is a decimal point
//Common table
uchar flash table[]={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
void show(uchar j,uchar k)
{
led_wei|=0x0F; //If the position is changed, this should also be changed to clear the screen
//Common anode and common cathode and high and low level drive are also different
led_wei&=~BIT(k);
/*if(k==1) //This is used to add a decimal point to the required position
{
led_duan=table[j]&0x7f;
delayms(4);
}*/
led_duan=table[j];
delayms(4);
}
/*****************Digital tube output function****************/
void led_display(uint dat,uchar num)//dat is the number to be output, num is the number of digits to be output
{
uchar i,ad[4];
led_duan_ddr;
led_wei_ddr;
for(i=0;i
ad[i]=dat%10;
dat=dat/10;
}
for(i=0;i
show(ad[i],i);
delayms(1);
}
}
/****************Delay function related file******************/
#ifndef __delay_H__
#define __delay_H__
extern void delayms(uint t);
#endif
/**************C file of one millisecond delay function********************/
#include "config.h"
/*********One millisecond delay function**********/
void delayms(uint t)
{
uint i,j;
for(i=0;i
for(j=0;j<1141;j++);
}
}
/***************Total header file*******************/
#ifndef __config_H__
#define __config_H__
#include
#include
#define uchar unsigned char
#define uint unsigned int
#include "delay.h"
#include "led.h"
#endif
/****************C file of the main function****************************/
#include "config.h"
void main()
{
while(1)
{
led_display(1234,4);
}
}
Previous article:Simple light-seeking car (including multi-channel AD sampling)
Next article:A simple 18B20 program
Recommended ReadingLatest update time:2024-11-16 12:43
- Popular Resources
- Popular amplifiers
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Metronom Real-Time Operating System RTOS for AVR microcontrollers
- Learn C language for AVR microcontrollers easily (with video tutorial) (Yan Yu, Li Jia, Qin Wenhai)
- Design of Network Sensor Node Based on FlexRay Bus
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How to use EPI general mode to communicate with FPGA in TM4c129 series microcontroller
- Before buying a cable fault tester, you must know about its manufacturer. How to find a good time...
- Buck-boost DCDC TPS63810 application in TWS earphones
- Purgatory Legend-IIC Battle
- CC3235S and CC3235SF SimpleLink Wi-Fi dual-band single-chip solutions
- Design of ESD protection structure for CMOS circuits
- 8 Common Uses of Diodes
- TMS320C6655 Fixed and Floating Point Digital Signal Processor
- [Digi-Key KOL Lecture] Common Techniques for Designing Low-Power DC-DC Converters
- Problems encountered in B-U585I-IOT02A test