?? main_key.c
字號:
/*
File name:main_key.c
Function: 利用定時器定時中斷來掃描鍵盤,并把鍵值顯示到LCM1602上
Author:ken
Date:2007-08-15
*/
#include <avr/io.h>
#include "2X8_key.h"
#include "lcm1602.h"
#include <util/delay.h>
//#include <inttypes.h>
#include <avr/interrupt.h>
#include "type.h"
/*
* Name:Timer0_init
* Function:定時器0初始化,定時21ms
* In:null
* Out:null
* Author:Ken
* Date:2007-08-15
*/
void Timer0_init(void)
{
TCNT0 = 0x1A; //set count
OCR0 = 0xE6; //set compare
TCCR0|= ((1<<CS02)|(1<<CS00)); //1024預分頻 0x05
TIMSK|= (1<<TOIE0); //允許TC0溢出中斷
}
SIGNAL(SIG_OVERFLOW0)
{
TCNT0 = 0x1A; //set count
key();
}
int main(void)
{
key_init();
Timer0_init();
LCM1602Init();
sei();
while(1)
{
unsigned char temp_key1;
temp_key1=key();
_delay_ms(50);
if(temp_key1==key())
{
//LCM1602Write_String(0,0,temp_key1);
LCM1602Write_number(temp_key1);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -