数码管表白(投稿用)

数码管表白

现在我们设想一个程序:
首先,我们让流水灯一个一个流,然后双向奔赴,到一定程度,全闪。就像感情,只有经过细水长流,双向奔赴,才能开花结果。
接下来,我们让数码管显示520 1314.YU,I CAN By YOUR SIDE FOREVER ,I LOVE YOU 。
我们先让它们一个一个显示出来,最终一句话就全体闪烁一下,最终到I LOVE YOU 的部分,我们就一直闪烁,和LED一起闪烁。

那么,我们开始逐步分析吧:
数字部分是肯定能显示出来的,所以我们研究字母部分就行了
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

这是大概的情况,虽然我们是沉迷于技术学习的孩子,但是,我们心里时时刻刻都想着对象,你们说是吧!赶紧自己设计一段话,设计好排版,考虑在目前这只有8个数码管的小板子上,表达对你女朋友的爱意吧!当然,你还可以考虑加入蜂鸣器的版本,就是让蜂鸣器唱歌,众所周知,振动是发声的来源,所以,蜂鸣器不同的振动频率和延时效果可以让单片机唱歌,阴乐不分高低!我不会

好嘞,开始编想程序吧!
我们可以考虑把字母的码子,先搞出来:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
好嘞!字母搞出来了!
现在开始把需要的2个定时器都设定好,主程序框架也设定好:
在这里插入图片描述
在这里插入图片描述
这是我们用到的中断
先 主框架:

#include <STC15F2K60S2.H>
#define uchar unsigned char
#define uint unsigned int
uchar t0,t1;
unsigned int code list[]={0xc0,0xf9,0x24,0x30,
0x19,0x12,0x02,0xf8,
0x00,0x10,0x08,0x03,
0x46,0x21,0x06,0x0e};

void time0() interrupt 1
{
		TH0 = (65536-50000)/256;
		TL0 = (65536-50000)%256;
		t0 +=1;
}
void time1() interrupt 3
{
		TH0 = (65536-50000)/256;
		TL0 = (65536-50000)%256;
		t1 +=1;
}
void delay(uint k)
{
		uint i = 0;
		uint j = 0;
		for(i=700;i>0;i--)
		{
				for(j=0;j<k;j++)
			{
					;
			}
		}
}

void initAll()
{
	TMOD = 0x00;
	TH0 = (65536 - 50000)/256;
	TL0	= (65536 - 50000)%256;
	TH1 = (65536 - 50000)/256;
	TL1	= (65536 - 50000)%256;
	EA = 1;
	ET0 = 1;
	ET1 = 1;
	TR0 = 1;
	TR1	= 1; 
}
void display()
{
	
}
void main(void)
{
	
	initAll();
	while(1)
	{
	}
}

接下来我们完善整个函数,根据自己想要的情形
我觉得520 1314 太土了,就没用了,加了别的

#include <STC15F2K60S2.H>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar t0,t1,wei,duan,flag1;
uchar oled1 = 0xfe;
uchar oled2 = 0x7f;

unsigned int code list[]={0xc0,0xf9,0x24,0x30,
0x19,0x12,0x02,0xf8,
0x00,0x10,0x08,0x03,
0x46,0x21,0x06,0x0e};

void time0() interrupt 1
{
		TH0 = (65536-50000)/256;
		TL0 = (65536-50000)%256;
		t0 +=1;
}
void time1() interrupt 3
{
		TH0 = (65536-50000)/256;
		TL0 = (65536-50000)%256;
		t1 +=1;
}
void delay(uint k)
{
		uint i = 0;
		uint j = 0;
		for(i=700;i>0;i--)
		{
				for(j=0;j<k;j++)
			{
					;
			}
		}
}

void InitAll()
{
	TMOD = 0x00;
	TH0 = (65536 - 50000)/256;
	TL0	= (65536 - 50000)%256;
	TH1 = (65536 - 50000)/256;
	TL1	= (65536 - 50000)%256;
	EA = 1;
	ET0 = 1;
	ET1 = 1;
	TR0 = 1;
	TR1	= 1; 
}
//void DisplayLed1()
//{
//	again:	
//		if(flag1 != 8)
//		{
//			flag1 += 1;
//			P2=((P2&0x1f)|0x80);
//			P0=oled1;
//			P2 &= 0x1f;
//			oled1 = _crol_(oled1,1);
//			t0 = 0;
//			goto again;
//		}
//		else
//			{
//				P2=((P2&0x1f)|0x80);
//				P0=0x00;
//				P2 &= 0x1f;
//				delay(100);
//				P2=((P2&0x1f)|0x80);
//				P0=0xff;
//				P2 &= 0x1f;
//				delay(100);
//				P2=((P2&0x1f)|0x80);
//				P0=0x00;
//				P2 &= 0x1f;
//			}

//}
//void DisplayLed2()
//{
//		oled2 = 0x7f;
//		P2=((P2&0x1f)|0x80);
//		P0=oled2;
//		P2 &= 0x1f;
//		oled2 = _cror_(oled2,1);
continue....	
//}
//void DisplaySmg1()
//{
//		wei = 0x01, 
5
//	  P2=((P2&0x1f)|0xc0);
//		P0=wei;
//		P2 &= 0x1f;
//		P2=((P2&0x1f)|0xe0);
//		P0=list[5];
//		P2 &= 0x1f;
//		delay(500);
2
//		wei<<=1;
//	  P2=((P2&0x1f)|0xc0);
//		P0=wei;
//		P2 &= 0x1f;
//		P2=((P2&0x1f)|0xe0);
//		P0=list[2];
//		P2 &= 0x1f;
//		delay(500);
0
//		wei<<=1;
//	  P2=((P2&0x1f)|0xc0);
//		P0=wei;
//		P2 &= 0x1f;
//		P2=((P2&0x1f)|0xe0);
//		P0=list[0];
//		P2 &= 0x1f;
//		delay(500);
1
//		wei<<=2;
//	  P2=((P2&0x1f)|0xc0);
//		P0=wei;
//		P2 &= 0x1f;
//		P2=((P2&0x1f)|0xe0);
//		P0=list[1];
//		P2 &= 0x1f;
//		delay(500);
3
//		wei<<=1;
//	  P2=((P2&0x1f)|0xc0);
//		P0=wei;
//		P2 &= 0x1f;
//		P2=((P2&0x1f)|0xe0);
//		P0=list[3];
//		P2 &= 0x1f;
//		delay(500);
1
//		wei<<=1;
//	  P2=((P2&0x1f)|0xc0);
//		P0=wei;
//		P2 &= 0x1f;
//		P2=((P2&0x1f)|0xe0);
//		P0=list[1];
//		P2 &= 0x1f;
//		delay(500);
4	
//		wei<<=1;
//	  P2=((P2&0x1f)|0xc0);
//		P0=wei;
//		P2 &= 0x1f;
//		P2=((P2&0x1f)|0xe0);
//		P0=list[4];
//		P2 &= 0x1f;
//		delay(500);
//}
void DisplaySmg2()
{
		wei = 0x01, 
//y
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x91;
		P2 &= 0x1f;
		delay(500);
//u
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0xc1;
		P2 &= 0x1f;
		delay(500);
//i
		wei<<=2;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0xcf;
		P2 &= 0x1f;
		delay(500);
//c
		wei<<=2;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x46;
		P2 &= 0x1f;
		delay(500);
//a
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x08;
		P2 &= 0x1f;
		delay(500);
//n
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0xc8;
		P2 &= 0x1f;
		delay(500);
}

void DisplaySmg3()
{
		wei = 0x02, 
//b
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x03;
		P2 &= 0x1f;
		delay(500);
//e
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x06;
		P2 &= 0x1f;
		delay(500);
//b
		wei<<=2;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x03;
		P2 &= 0x1f;
		delay(500);
//y
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x91;
		P2 &= 0x1f;
		delay(500);

}
void DisplaySmg4()
{
		wei = 0x01, 
//y
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x91;
		P2 &= 0x1f;
		delay(500);
//0
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0xc0;
		P2 &= 0x1f;
		delay(500);
//u
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0xc1;
		P2 &= 0x1f;
		delay(500);
//r
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0xce;
		P2 &= 0x1f;
		delay(500);
//s
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x12;
		P2 &= 0x1f;
		delay(500);
//i
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0xcf;
		P2 &= 0x1f;
		delay(500);
//d
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x21;
		P2 &= 0x1f;
		delay(500);
//e
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x06;
		P2 &= 0x1f;
		delay(500);
}
	void DisplaySmg5()
{
		wei = 0x01;
//i
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0xcf;
		P2 &= 0x1f;
		delay(500);
//l
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0xc7;
		P2 &= 0x1f;
		delay(500);
//0
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0xc0;
		P2 &= 0x1f;
		delay(500);
//v
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0xc1;
		P2 &= 0x1f;
		delay(500);
//e
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x06;
		P2 &= 0x1f;
		delay(500);
//y
    wei <<= 1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x91;
		P2 &= 0x1f;
		delay(500);
//0
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0xc0;
		P2 &= 0x1f;
		delay(500);
//u
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0xc1;
		P2 &= 0x1f;
		delay(500);
}
void DisplaySmg6()
{
		wei = 0x01, 
//b
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x03;
		P2 &= 0x1f;
		delay(500);
//e
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x06;
		P2 &= 0x1f;
		delay(500);
//H	
		wei<<=2;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x89;
		P2 &= 0x1f;
		delay(500);
//A	
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x08;
		P2 &= 0x1f;
		delay(500);
//P	
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x8C;
		P2 &= 0x1f;
		delay(500);
//P	
		wei<<=1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x8C;
		P2 &= 0x1f;
		delay(500);
//y
    wei <<= 1;
	  P2=((P2&0x1f)|0xc0);
		P0=wei;
		P2 &= 0x1f;
		P2=((P2&0x1f)|0xe0);
		P0=0x91;
		P2 &= 0x1f;
		delay(500);
}
void main(void)
{
	P2=((P2&0x1f)|0xa0);
	P0=0;
	P2 &= 0x1f;
	InitAll();
	DisplaySmg2();
	delay(500);
	DisplaySmg3();
	delay(500);
	DisplaySmg4();
	delay(500);
	DisplaySmg5();
	delay(500);
	DisplaySmg6();
}

你们可以改我的代码。可以考虑一下时间的管理,因为我失败了,直接就上了,没用定时器了。
视频是我对象一个人的私有浪漫,就不放在博客里面了。
大家可以自己弄出来,发给对象。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值