Single digital tube displays 4x4 matrix buttons

Publisher:Joyful444LifeLatest update time:2022-01-13 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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:

insert image description here

Reference address:Single digital tube displays 4x4 matrix buttons

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
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号