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

📄 demo_6_9.c

📁 AVR单片机嵌入式系统原理与应用实践例码
💻 C
字号:
/*********************************************
File name           : Demo_6_9.c
Chip type           : ATmega16
Program type        : Application
Clock frequency     : 4.000000 MHz
Memory model        : Small
External SRAM size  : 0
Data Stack size     : 256
*********************************************/
#include <mega16.h>
// Alphanumeric LCD Module functions
#asm
   .equ __lcd_port=0x15
#endasm
#include <lcd.h>

typedef unsigned char byte;

/* table for the user defined character */
flash byte char0[8]={		// 天的字型
0b0011111,
0b0000100,
0b0000100,
0b0011111,
0b0000100,
0b0000100,
0b0001010,
0b0010001};
flash byte char1[8]={		// 向的字型
0b0000100,
0b0001000,
0b0011111,
0b0010001,
0b0011111,
0b0011011,
0b0011111,
0b0010001};
flash byte char2[8]={		// 上的字型
0b0000100,
0b0000100,
0b0000111,
0b0000100,
0b0000100,
0b0000100,
0b0000100,
0b0011111};

/* function used to define user characters */
void define_char(byte flash *pc,byte char_code)
{
	byte i,a;
	a=(char_code<<3) | 0x40;
	for (i=0; i<8; i++) lcd_write_byte(a++,*pc++);
}

void main(void)
{
	lcd_init(16);			// initialize the LCD for 2 lines & 16 columns

	define_char(char0,0);  // define user character 0
	define_char(char1,1);  // define user character 1
	define_char(char2,2);  // define user character 2
	lcd_clear();
	lcd_putsf("Demo_6_9.c");	// 第一行显示内容
	lcd_gotoxy(0,1);
	lcd_putsf("User define:");	// 第二行显示内容
	lcd_putchar(0);			    // 接在后面显示"天天向上"
	lcd_putchar(0);
	lcd_putchar(1);
	lcd_putchar(2);
	while (1);
}

⌨️ 快捷键说明

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