⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3510test.c

📁 这是一个使用NOKIA 3510I的液晶屏+AVR单片机来制作的电压表
💻 C
字号:
//3510test.c : source file for the 3510test project
//

#include "3510test.h"
#include "3510.h"
#include "3510testADC.h"

/////////////////////////////////////////////////////////////////////////////
//3510test

unsigned char  str[]="AVR ADC TEST";
unsigned char  data[]="2.5600V";

static void io_init(void)
{
	//{{WIZARD_MAP(General)
	//}}WIZARD_MAP(General)

	//{{WIZARD_MAP(I/O Ports)
	// PortB
	PORTB = 0x0;
	DDRB = 0x0;
	// PortC
	PORTC = 0x0;
	DDRC = 0x0;
	// PortD
	PORTD = 0x0;
	DDRD = 0x0;
	//}}WIZARD_MAP(I/O Ports)

	//{{WIZARD_MAP(Watchdog)
	// Watchdog Disabled
	wdt_disable();
	//}}WIZARD_MAP(Watchdog)

	//{{WIZARD_MAP(Analog Comparator)
	// Analog Comparator Disabled
	ACSR = 0x80;
	//}}WIZARD_MAP(Analog Comparator)
}

int main(void)
{		unsigned int adc_data,j,tempcount;
	unsigned char i;
	//{{WIZARD_MAP(Initialization)
	io_init();
	adc_init();
	//}}WIZARD_MAP(Initialization)
	// TODO: Add extra initialization here
	

	
	LCD_Initialize();
	LCD_ColorSet(FALSE);
	LCD_Clear(FALSE);

	//{{WIZARD_MAP(Global interrupt)
	sei();
	//}}WIZARD_MAP(Global interrupt)	
	LCD_Drawhz(1,10,str,sizeof(str)-1,0,0x1f);
	while(1)
	{


	// Read the ADC conversion result
	adc_data = ADCW;
	// TODO: Add your code here
	
	j=((25600/1023)*(adc_data));

				tempcount=j;

			for(i=6;i>0;i--)   //取出每位中的数据
			{
				if (i!=2)
				{
				data[i-1]=tempcount%10+48;
				tempcount/=10;
				}
			}
LCD_Drawhz(25,40,data,sizeof(data)-1,0,0x1f);

Delay5Ms();	// TODO: Add your code here
		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -