Ä¿¹Â´ÏƼ>ÀÚ·á½Ç
   
   
 
    Tact Switvh Detect¹æ¹ý 1 Edge Exchange Detect   2013.01.25
    Tact Switvh Detect¹æ¹ý 1 Edge Exchange Detect
   
 

º» ³»¿ëÀº ¸¶ÀÌÄÄÀ¸·Î ¿ÜºÎ Push Swich¸¦ ÀÔ·Â ¹ÞÀ½¿¡ ÀÖ¾î xor ·ÎÁ÷(µÎ ÀÔ·ÂÀÌ °°À¸¸é 0, ´Ù¸£¸é 1À» Ãâ·ÂÇÔ)À» ÀÌ¿ëÇÑ °ÍÀÔ´Ï´Ù.

#define KEY_CHA 0x01
#define KEY_CHB 0x02

unsigned char KeyInCount,KeyInValue,KeyInTempBuffer,KeyInOldValue,KeyTemp;

//ŸÀ̸Ӹ¦ ÀÌ¿ëÇÏ¿© ÀÏÁ¤ÇÑ tickÀ¸·Î Æ÷Æ®·Î ºÎÅÍ ÀÔ·ÂÀ» ½ºÄµÇÑ´Ù.

// Timer 0 overflow interrupt service routine
#pragma savereg+
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
// Place your code here
TCNT0=0xB5;
b4msec=1;
#asm("wdr"); //complement
KeyInDetect();

}
#pragma savereg-

//½ÇÁ¦ ½ºÄµÇÏ°í ÀÌÀüÀÇ °ª°ú ºñ±³ÇÏ°í KeyÀÇ Ã¤Å͸µÀ» Á¦°ÅÇÑ´Ù.

void KeyInDetect(void)
{
KeyTemp=~(PINB & 0x03);
if(KeyInTempBuffer == KeyTemp){
if(KeyInCount==5){
KeyInCount=6;
KeyInValue=KeyTemp;
}
else{
if(KeyInCount<5){
++KeyInCount;
}
}
}
else{
KeyInTempBuffer = KeyTemp;
KeyInCount=0;
}
}

//detectµÈ Å° °ªÀ» ó¸®ÇÑ´Ù.

//º» ÇÔ¼ö´Â while¹® ¼Ó¿¡ µÐ´Ù-Áï Æú¸µÃ³¸®ÇÑ´Ù.

void KeyProc(void)
{
unsigned char val;
val= KeyInValue ^ KeyInOldValue;
if(val){
if(val & KEY_CHA){
if(KeyInValue & KEY_CHA){
//Å°ÀÇ »óÅ°¡ Low¿¡¼­ High·Î º¯Çß½¿

}
else{
//Å°ÀÇ »óÅ°¡ High¿¡¼­ Low·Î º¯Çß½¿

}
}
if(val & KEY_CHB){
if(KeyInValue & KEY_CHB){
//Å°ÀÇ »óÅ°¡ Low¿¡¼­ High·Î º¯Çß½¿

}
else{
//Å°ÀÇ »óÅ°¡ High¿¡¼­ Low·Î º¯Çß½¿

}
}
KeyInOldValue=KeyInValue;
}
}


 
 
   
 
ÁÖ¼Ò: ÀÎõ±¤¿ª½Ã ¼­±¸ ºÀ¼ö´ë·Î 141 °¡Á½ùü°ø´Ü Bµ¿ 505È£    ´ëÇ¥ÀÚ : ±è½Ã¼®    ÀüÈ­¹øÈ£ : 032)672-2966    Æѽº¹øÈ£ : 032)672-2965
»ç¾÷ÀÚµî·Ï ¹øÈ£ : 225-14-00080    ÄÜÆ®·Ñ·¯°³¹ß,ÀüÀÚÁ¦Ç°°³¹ß ¾ÆÅ×Å©