stc单片机用数码管显示i love you(键盘版)

时间:2022-05-20 17:21:12 阅读: 最新文章 文档下载
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。
stc 单片机用数码管显示 i love you(键盘版)

#include#define uchar unsigned char#define uint unsigned intuchar

led[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};uchar key[3]={0xfe,0xfd,0xfb};unsigned for(i=0;i<3;i++) { case

char

get(){

uchar

x,y,lie,i;

x=0;y=0;

P1=key[i];lie=P1&0x38;if(lie!=0x38){

case

0x28:{y=2;}break;

x=i+1;switch(lie){ 0x18:{y=3;}break;

0x30:{y=1;}break; case

default:{x=0;}break;}break;}} if(x!=0) return (3*(x-1)+y); else return 0;}void main(){uchar play=get();

play,i;P2M0=0xff;P2M1=0x00;P1M0=0xff;P1M1=0x00;while(1){

switch(play){case

1:{

P2=led[1];

P0=0x07;

for(i=0;i<100;i++);}break;case 2:{ P2=0x38; P0=0x0e; for(i=0;i<100;i++); P0=0x0f; P2=0x3f;

P0=0x0d

;

for(i=0;i<100;i++);

P0=0x0f;

P2=0x3e;

P0=0x0b;

for(i=0;i<100;i++); P0=0x0f; P2=0x79; P0=0x07; for(i=0;i<100;i++);}break;case 3:{ P2=0x6e;P0=0x0d;for(i=0;i<100;i++);P0=0x0f;P2=0x3f;P0=0x0b;for(i=0;i<100;i++);P 0=0x0f;P2=0x3e;P0=0x07;for(i=0;i<100;i++);}break;default }}}tips:感谢大家的阅读,本文由我司收集整编。仅供参阅!

:{P2=led[0];}break;


本文来源:https://www.wddqw.com/doc/518b3c9b59fb770bf78a6529647d27284a7337d4.html