Code:
#include #define uchar unsigned char #define uint unsigned int sbit BEEP = P3^7; uchar code DSY_CODE[]= { 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0x00 }; fly Pre_KeyNO = 16,KeyNO = 16; void DelayMS(uint ms) { flying t; while(ms--) { for(t=0;t<120;t++); } } void Keys_Scan() { volatile Tmp; P1 = 0x0f; DelayMS(1); Tmp = P1 ^ 0x0f; switch(Tmp) { case 1: KeyNO = 0; break; case 2: KeyNO = 1; break; case 4: KeyNO = 2; break; case 8: KeyNO = 3; break; default: KeyNO = 16; } P1 = 0xf0; DelayMS(1); Tmp = P1 >> 4 ^ 0x0f; switch(Tmp) { case 1: KeyNO += 0; break; case 2: KeyNO += 4; break; case 4: KeyNO += 8; break; case 8: KeyNO += 12; } } void Beep() { flying i; for(i=0;i<100;i++) { DelayMS(1); BEEP = ~BEEP; } BEEP = 1; } void main() { P0 = 0x00; while(1) { P1 = 0xf0; if(P1 != 0xf0) Keys_Scan(); if(Pre_KeyNO != KeyNO) { P0 = ~DSY_CODE[KeyNO]; Beep(); Pre_KeyNO = KeyNO; } DelayMS(100); } } Hardware Connection:
Previous article:MCU INT0 and INT1 counters
Next article:INTO interrupt counter
Recommended posts
- INA128 Instrument Amplifier
- ThetheoreticalamplificationfactorofINA128is100timeswhenRG=500ohms.Whentheinputis150KHz,10mVAC,itsamplificationfactorremainsalmostunchanged.Whyisitlikethis? Itisnotrecommendedtousesimulationsoftware,itisalsog
- 菠萝包_ Analog electronics
- Tantalum is easy to break down
- Asshowninthefigure,12Vuses25V100Etantalumcapacitors,whicharepronetobreakdownandhaveafailurerateof7% Ifthepictureintheposter'spictureisalinearregulator,thenitissuspectedthatthereisaproblemwiththedevicequa
- hoveyhxb Power technology
- i.MX6ULL Terminator QT Application Development Qt for Android
- QTisaverygoodcross-platformtool.SoweonlyneedtomasterthemethodofQTtomaketheinterface,andwecaneasilymakeQTcross-platformapplications. WhyshouldwelearnQT_For_Android? 1.ExperiencethesuperiorityofQTcross-platform
- 遥寄山川 ARM Technology
- Control the state of multiple IOs through the serial port
- Purposeofcode:Thereare50IOportstobecontrolled,allofwhicharehighlevelinstaticstate.NowyouneedtousetheserialporttocontroltheIOportstobepulledlow.Youcanselectanyofthe50portstobepulledlow.Forexample,if
- guominele stm32/stm8
- Low power consumption issue after stm32 upgrade in IAP mode
- Whenthestm32f103isturnedon,itwillenterthestopmode.IntheenvironmentwithoutIAPmode,itcanre-initializetheconfigurationafterbeingawakenedbythekeyexternalinterruptandenterthenormalworkingmode;butintheIAPmodeafter
- ddjc stm32/stm8
- White Paper Sharing! Design Challenges and Considerations of Brushless DC Motors and Their Drivers
- Ijustfoundsomeusefulinformation!Ifyouneedit,pleasesaveitanddownloadit!! DesignChallengesandConsiderationsforBrushlessDCMotorsandTheirDrivers https://www.eeworld.com.cn/aqvDS08 Abriefintroduction: Goodinf
- okhxyyo Power technology
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Moderator Rewards Announcement for March and April 2019
- Switching Circuit
- [RVB2601 Creative Application Development] My Guitar Environmental Protector - Automatic Dry and Humidity Regulator
- 【NXP Rapid IoT Review】 NO2. Experience Sharing of Mobile App BLE Control Development Kit
- What is the role of Zigbee wireless data transmission module in wireless personal area network?
- Problems with STM32CubeMX generating serial port 1 interrupt initialization code
- What is unity gain frequency?
- TI 2803x DSP chip LIN communication baud rate adaptation
- Are UWB devices the future trend?
- Please tell me what's going on.