欢迎来金海湾博客
Yanling164

https://blog.jinbay.com/Yanling164/  复制链接收藏

Yanling164个人头像
Yanling164
博客日历
«November 2024»
12
3456789
10111213141516
17181920212223
24252627282930
博客自定义分类
5/28/2009 7:19:00 PM [语言学习] 分享

分享

带返回值的子程序
#include                          头文件
#define uint unsigned int   
#define uchar unsigned char                  宏定义
 
sbit key1=P3^4;  
sbit dula=P2^6;
sbit wela=P2^7;                            按键 位选 段选
uchar code table[]={                        数组
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,0
};
uchar num,temp,num1;                      变量声明
void delay(uint z)                           延时子程序
{
       uint x,y;
       for(x=z;x>0;x--)
              for(y=110;y>0;y--);      
}
uchar keyscan();                           声明带返回值的子程序
 
void main()                                主函数
{
       num=17;
       dula=1;
       P0=0;
       dula=0;
       wela=1;
       P0=0xc0;
       wela=0;
       while(1)
              {
                     num1=keyscan();                   num1等于函数KEYSCAN的返回值
                     dula=1;
                     P0=table[num1-1];                  显示数组对应的数字
                     dula=0;                          
             
              }
 
}
uchar keyscan()                                带返回值的子程序    矩阵键盘扫描程序
{
       P3=0xfe;
                     temp=P3;
                     temp=temp&0xf0;
                     while(temp!=0xf0)
                            {
                                   delay(5);
                                   temp=P3;
                                   temp=temp&0xf0;
                                   while(temp!=0xf0)
                                   {
                                          temp=P3;
 
                     switch(temp)
                            {
                                   case 0xee:num=1;
                                          break;
                                   case 0xde:num=2;
                                          break;
                                   case 0xbe:num=3;
                                          break;
                                   case 0x7e:num=4;
                                          break;
                            }
                            while(temp!=0xf0)
                            {
                                   temp=P3;
                                   temp=temp&0xf0;
                            }
                            }
                            }
                     P3=0xfd;
                     temp=P3;
                     temp=temp&0xf0;
                     while(temp!=0xf0)
                            {
                                   delay(5);
                                   temp=P3;
                                   temp=temp&0xf0;
                                   while(temp!=0xf0)
                                   {
                                          temp=P3;
 
                     switch(temp)
                            {
                                   case 0xed:num=5;
                                          break;
                                   case 0xdd:num=6;
                                          break;
                                   case 0xbd:num=7;
                                          break;
                                   case 0x7d:num=8;
                                          break;
                            }
                            while(temp!=0xf0)
                            {
                                   temp=P3;
                                   temp=temp&0xf0;
                            }
                            }
                            }
                     P3=0xfb;
                     temp=P3;
                     temp=temp&0xf0;
                     while(temp!=0xf0)
                            {
                                   delay(5);
                                   temp=P3;
                                   temp=temp&0xf0;
                                   while(temp!=0xf0)
                                   {
                                          temp=P3;
 
                     switch(temp)
                            {
                                   case 0xeb:num=9;
                                          break;
                                   case 0xdb:num=10;
                                          break;
                                   case 0xbb:num=11;
                                          break;
                                   case 0x7b:num=12;
                                          break;
                            }
                            while(temp!=0xf0)
                            {
                                   temp=P3;
                                   temp=temp&0xf0;
                            }
                            }
                            }
                     P3=0xf7;
                     temp=P3;
                     temp=temp&0xf0;
                     while(temp!=0xf0)
                            {
                                   delay(5);
                                   temp=P3;
                                   temp=temp&0xf0;
                                   while(temp!=0xf0)
                                   {
                                          temp=P3;
 
                     switch(temp)
                            {
                                   case 0xe7:num=13;
                                          break;
                                   case 0xd7:num=14;
                                          break;
                                   case 0xb7:num=15;
                                          break;
                                   case 0x77:num=16;
                                          break;
                            }
                            while(temp!=0xf0)
                            {
                                   temp=P3;
                                   temp=temp&0xf0;
                            }
                            }
                            }
return num;                                        将num返回值送回主函数
}
 
带返回值带显示子函数的子程序
#include
#define uint unsigned int   
#define uchar unsigned char 
 
sbit key1=P3^4;
sbit dula=P2^6;
sbit wela=P2^7;
uchar code table[]={  
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,0
};
uchar num,temp,num1;
void delay(uint z)             
{
       uint x,y;
       for(x=z;x>0;x--)
              for(y=110;y>0;y--);      
}
uchar keyscan();
void display(uchar aa);
 
void main()
{
       num=17;
       dula=1;
       P0=0;
       dula=0;
       wela=1;
       P0=0xc0;
       wela=0;
       while(1)
              {
             
                     display(keyscan());
             
              }
}
void display(uchar aa)
{
       dula=1;
       P0=table[aa-1];
       dula=0;
}
 
uchar keyscan()
{
       P3=0xfe;
                     temp=P3;
                     temp=temp&0xf0;
                     while(temp!=0xf0)
                            {
                                   delay(5);
                                   temp=P3;
                                   temp=temp&0xf0;
                                   while(temp!=0xf0)
                                   {
                                          temp=P3;
 
                     switch(temp)
                            {
                                   case 0xee:num=1;
                                          break;
                                   case 0xde:num=2;
                                          break;
                                   case 0xbe:num=3;
                                          break;
                                   case 0x7e:num=4;
                                          break;
                            }
                            while(temp!=0xf0)
                            {
                                   temp=P3;
                                   temp=temp&0xf0;
                            }
                            }
                            }
                     P3=0xfd;
                     temp=P3;
                     temp=temp&0xf0;
                     while(temp!=0xf0)
                            {
                                   delay(5);
                                   temp=P3;
                                   temp=temp&0xf0;
                                   while(temp!=0xf0)
                                   {
                                          temp=P3;
 
                     switch(temp)
                            {
                                   case 0xed:num=5;
                                          break;
                                   case 0xdd:num=6;
                                          break;
                                   case 0xbd:num=7;
                                          break;
                                   case 0x7d:num=8;
                                          break;
                            }
                            while(temp!=0xf0)
                            {
                                   temp=P3;
                                   temp=temp&0xf0;
                            }
                            }
                            }
                     P3=0xfb;
                     temp=P3;
                     temp=temp&0xf0;
                     while(temp!=0xf0)
                            {
                                   delay(5);
                                   temp=P3;
                                   temp=temp&0xf0;
                                   while(temp!=0xf0)
                                   {
                                          temp=P3;
 
                     switch(temp)
                            {
                                   case 0xeb:num=9;
                                          break;
                                   case 0xdb:num=10;
                                          break;
                                   case 0xbb:num=11;
                                          break;
                                   case 0x7b:num=12;
                                          break;
                            }
                            while(temp!=0xf0)
                            {
                                   temp=P3;
                                   temp=temp&0xf0;
                            }
                            }
                            }
                     P3=0xf7;
                     temp=P3;
                     temp=temp&0xf0;
                     while(temp!=0xf0)
                            {
                                   delay(5);
                                   temp=P3;
                                   temp=temp&0xf0;
                                   while(temp!=0xf0)
                                   {
                                          temp=P3;
 
                     switch(temp)
                            {
                                   case 0xe7:num=13;
                                          break;
                                   case 0xd7:num=14;
                                          break;
                                   case 0xb7:num=15;
                                          break;
                                   case 0x77:num=16;
                                          break;
                            }
                            while(temp!=0xf0)
                            {
                                   temp=P3;
                                   temp=temp&0xf0;
                            }
                            }
                            }
return num;
}
 阅读全文>>

评论

分享 分享

对话:

我要刊登广告
我要刊登广告
5/28/2009 9:30:00 PM [] 分享

分享


  碎碎的刘海搭配凌乱的麻花辫,不但不显得过时老气,而且甜美气息十足。

  慵懒盘发,用点小小的美发道具就可以让你的头发跟着你的着装打扮72变。随时应付各种约会,让你的约会跟你的发型一样的甜美!

  不妨学学鲜嫩派女星马苏的美发高招:时尚深棕发色加一丝紫色挑染。

  端庄简洁的盘发,更适合上班的你,但是同样都会令你看上去既清纯又可爱。又不失大气的分度。

  复古刘海搭配长卷发,丰盈蓬蓬头顶是时尚发型的关键哦。

  如果你想要通过发型扮甜美,不妨学学鲜嫩派女星马苏的美发高招:棕红长卷发+碎刘海。

  这几乎是一个人人都能拷贝的发型,甜...阅读全文>>

阅读(88)评论(0)

5/28/2009 3:10:00 PM [新闻时事] 分享

分享

现代中国人穷得只剩下“家”了
 
一、现象:顾家让中国人穷上加穷</STRONG>
中国人由于所在的国度,至今仍然没有摆脱农业文明对应下的熟人社会的格局,政治的力量过于集中和强大,社会自治的严重萎缩,因此,不得不顾家。家成了抵抗社会风险的港湾。也因此,中国人在经济上,将所有的金钱和资本倾注于自己的家,而不愿亦无力为社会、为他人付出一丁点,所以,中国人不得不自私。
家是一个远离“王法”的地方。而在各自的家中,由于有了血缘关系,所以就没有了对、错之分,一切都好说好商量,一切都可以和稀泥。因此,中国人在社会生活中,一直无法培养出独立的社会人格,故中国人在人格上是不健全的。我们受了委屈,采取的办法往往是“撒娇”,因为有家长的庇护;一旦这种庇护不成功,很多人的心理防线就会彻底崩溃,有的以至走上极端,因此,我曾经写过一篇文章叫《撒娇:中国式自杀的原因》。
有一首流行歌曲叫《有钱没钱回家过年》,反映的就是中国人的共同心声。年头的南方雪灾让人产生了很多思考,对中国社会的深层次矛盾的思考。中国现在仍然是一个为世界“打工”的国家。“打工仔”、“打工妹”们之所以每年逢年过节花光积蓄,其错误就是

阅读(76)评论(0)

© 2024 Jinbay.com All rights reserved. 版权所有金海湾。 未经许可,不得转载。