#define uchar unsigned char
#define uint unsigned int
uchar Table[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar Da
void DelayMs(uint i) //0.25ms
{uchar j;
for(;i!=0;i--)
{for(j=250;j!=0;j--) {;}}
}
void Display(uchar *p) //Display {uchar i,sel=0x01;
for(i=0;i<4;i++)
{PORTB=sel;
PORTC=0xff-Table[p[i]];
DelayMs at 5ms interval (20);
sel=sel<<1;
}
}
uint ADC_Convert(void)
{uint temp1,temp2;
temp1=(uint)ADCL;
temp2=(uint)ADCH;
temp2=(temp2<<8)+temp1;
return(temp2);
}
void Process(uint i,uchar *p)
{p[0]=i/1000;
i=i%1000;
p[1]=i/100;
i=i%100;
p[2]=i/10;
i=i%10;
p[3]=i;
}
/*
void Timer0_Init(void)
{SREG=SREG|0x80; //Global disconnect;
TIMSK=TIMSK|0x01; //T/C0 overflow interrupt enable;
TCCR0=0x05; //CLK/1024; 128uS
TIFR=0x01; //T/C0 interrupt flag write 1 to clear 0;
TCNT0=256-125; //125*128us=16ms
}*/
void main(void)
{uint i;
//Set port A to input without pull-up;
DDRA=0x00;
PORTA=0x00;
//Set port B to push-pull 1 output;
DDRB=0xff;
PORTB=0xff;
//Set port C to push-pull 1 output;
DDRC=0xff;
PORTC=0xff;
//Initialize port B to output 1; initialize port C to output 0; light up all digital tubes;
PORTB=0xff;
PORTC=0x00;
//ADC initialization;
ADMUX=0x02; //Select the third channel;
ADCSR=0xe6; //125K conversion rate, free conversion mode; start AD converter;
//Delay until the system is stable;
DelayMs(3000);
while(1)
{i=ADC_Convert();
Process(i,Data
Display(
}
}
/*#pragma interrupt_handler Timer0:10
void Timer0()
{Int_Cnt+=1;
// Timer0_Init();
}*/
Previous article:AVR Eeprom C language programming
Next article:ATmega16L learning board 18B20 test program
Recommended ReadingLatest update time:2024-11-16 21:35
- 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)
- ATmega16 MCU C language programming classic example (Chen Zhongping)
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
- Popular power supply design
- MAX232cse chip introduction
- [Fudan Micro FM33LG0 Series Development Board Review] Driving SPI TFT Display
- Come to Infineon flagship store to find good things in autumn! Get coupons and win a 50-yuan JD card
- [2022 Digi-Key Innovation Design Competition] Material unboxing ESP32-S3 SHT30 LMG5200 and other devices
- Help, power circuit analysis
- If there is a bug in the third-party code, how can everyone adapt it to the original version after it is fixed?
- Share a general good book Digital Signal Processing C Language Program Collection-DSP Algorithm Encyclopedia C Language Version Original Book
- TMS320C6000 Image Library (IMGLIB)
- I'm just learning about MEMS. Does anyone know what the problem is with the unicleo GUI not being able to recognize the MEMS expansion board?