#include
0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xff};
uchar key_io;
PORTD=0XF0;
Delayms(5);
key_io=PIND & 0xf0;
if(key_io !=0xf0)
{
PORTD=0XF0;
Delayms(1);
key_io=PIND & 0xf0;
if(key_io !=0xf0)
{
key_val=key_scan();
key_val |= key_io ;
}
switch(key_val)
{
case 0xee: key_val=0x00; break; //Key K1
case 0xde: key_val=0x01; break; //Key K2
case 0xbe: key_val=0x02; break; //Key K3
case 0x7e: key_val=0x03; break; //Key K4
case 0xed: key_val=0x04; break; //Key K5
case 0xdd: key_val=0x05; break; //Key K6
case 0xbd: key_val=0x06; break; //Key K7
case 0x7d: key_val=0x07; break; //Key K8
case 0xeb: key_val=0x08; break; //Press key K9
case 0xdb: key_val=0x09; break; //Key K10
case 0xbb: key_val=0x0a; break; //Key K11
case 0x7b: key_val=0x0b; break; //Key K12
case 0xe7: key_val=0x0c; break; //Key K13
case 0xd7: key_val=0x0d; break; //key K14
case 0xb7: key_val=0x0e; break; //Key K15
case 0x77: key_val=0x0f; break; //key K16
}
}
PORTD=0XF0;
key_io=PIND & 0xf0;
while(key_io !=0xf0)
{
key_io=PIND & 0xf0;
}
PORTC=led_discode[key_val];
DDRA=0XFF;
PORTB=0XFF;
PORTD=0XF0;
fly m,temp=0xf7;
PORTD=temp | 0xf0;
Delayms(1);
return(temp & 0x0f);
uint i,j;
for( i=0;i
for(j=0;j<1141;j++);
Keywords:AVR128
Reference address:AVR128 Program - Matrix Buttons
#include
#define uchar unsigned char
#define uint unsigned int
void Delayms(uint MS);
uchar key_scan(void);
void init_io(void);
uchar led_discode[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
uchar key_val=0;
void main (viod)
{
init_io();
while(1)
{
}
}
void init_io(void)
{
PORT=0XFF;
DDRB=0XFF;
DDRC=0XFF;
PORTC=0XFF;
DDRD=0X0F;
DDRF=0X0E;
PORTF=0X0E;
PORTF&=0XF7;
DDRB |=0X10;
PORTB|=0X10;
}
uchar key_scan(void)
{
for(m=0;m<4;m++)
{
if((PIND & 0XF0)!=0XF0)
temp>>=1;
}
}
void Delayms(uint MS)
{
}
Previous article:AVR128 program - external interrupt
Next article:AVR128 Program - Blink a Single LED
- Popular Resources
- Popular amplifiers
- Example interpretation of 51 single chip microcomputer complete learning and application
- Example interpretation of 51 single chip microcomputer complete learning and application
- Application of AVR microcontroller Atmega128 in FPGA configuration
- AVR microcontroller atmega128 controls the angle of the servo sg90
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
Guess you like
- FPGA implementation of parallel fast FIR filter.pdf
- 【Radio Waves】What is the source of Bluetooth? Does it have any radiation that may affect your health? Is it safe?
- Beetle ESP32-C3 test (Part 3) IDF method to connect to wifi
- vsim-SDF-3250 error handling
- The minimum input voltage of a single-supply VI converter op amp is related to the load
- What are the pull-up and pull-down capabilities of a 0-10V dimmer?
- [ATmega4809 Curiosity Nano Review] Serial Communication
- What is a microcontroller
- Problems with Bluetooth Low Energy modules
- Understanding of feedback and operational amplifiers in circuits