Voltmeter Effect
电路原理图如下:
单片机源码:
#include
#include
#define uchar unsigned char
#define uint unsigned int
void delayms(uint mS) //微秒
{
uint i,j;
for( i=0;i
}
unsigned char disp[] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,
0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};
uint ADC_Value;
void port_init(void)
{
DDRD = 0xff;
PORTD= 0x00;
DDRE = 0xff;
PORTE= 0x00;
DDRF = 0x00;
PORTF= 0x00;
}
void adc_init(void)
{
ADMUX = 0x00;
ADCSRA= 0x00;
ACSR =1<
uint ADC_read(void)
{
uint ADC_L,ADC_H,temp;
ADCSRA |= (1<<ADSC);
ADC_L = ADCL;
ADC_H = ADCH;
temp = (ADCH<<8)|ADC_L;
return temp;
}
uint convert(uint data)
{
long temp1;
uint temp2;
temp1 = ((500 * (long)data)>>10);
temp2 = (uint)temp1;
return temp2;
}
void main(void)
{
uint voltage;
uchar n;
port_init();
adc_init();
DDRA=0XFF;
PORTA=0XFF;
DDRC=0XFF;
PORTC=0X00;
DDRF|=0X0E;
PORTF|=0X0E;
PORTF&=0xF7;
PORTA=0X00;
DDRB |=0X10;
PORTB|=0X10;
while(1)
{
ADC_Value = ADC_read(); //读取AD寄存器中的数值
voltage = convert(ADC_Value); //计算实际的输入电
for(n=0;n<50;n++)
display(voltage); //显示
}
Previous article:ATmega16 Minimum System Hardware Design
Next article:AVR M16 MCU NRF2401 Wireless Communication Development Kit
Recommended ReadingLatest update time:2024-11-15 15:05
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- 【Wireless closed-loop feedback system for desktop robotic arms】
- 8/21-22@Wuhan! Intel/World Peace Group invites you to participate in the Artificial Intelligence Technology Introduction and Implementation Seminar
- Professor Li Xia: How basic should basic research be?
- 【i.MX6ULL】Driver Development 11——LCD Driver Practice
- Microcontroller interview question collection
- HEF4051 is easy to damage
- Microchip Automotive Innovation Series Online Seminar Invites You to Attend!
- [STM32WB55 review]——by damiaa
- 【DIY Creative LED】WS2812 test successful
- RISC-V MCU Development (XII): Command Line Operations