4*4键盘扫描C程序
4*4键盘扫描C程序
#include<reg52.h>
#define uchar unsigned char
uchar code table[]={0xC0,0xF9,0xA4,0xB0,0x99,
0x92,0x82,0xF8,0x80,0x90,
0x88,0x83,0xC6,0xA1,0x86,0x8E};
uchar temp,num;
void display(uchar);
void delay(uchar a)
{
uchar b;
for(;a>0;a--)
for(b=200;b>0;b--);
}
void main()
{
while(1)
{
P2=0x7f;
temp=P2;
temp&=0x0f;
if(temp!=0x0f)
{
delay(50);
if(temp!=0x0f)
{
switch(temp)
{
case 0x07: num="0"; break;
case 0x0b: num="1"; break;
case 0x0d: num="2"; break;
case 0x0e: num="3"; break;
}
}
}
P2=0xbf;
temp=P2;
temp&=0x0f;
if(temp!=0x0f)
{
delay(50);
if(temp!=0x0f)
{
switch(temp)
{
case 0x07: num="4"; break;
case 0x0b: num="5"; break;
case 0x0d: num="6"; break;
case 0x0e: num="7"; break;
}
}
}
P2=0xdf;
temp=P2;
temp&=0x0f;
if(temp!=0x0f)
{
delay(50);
if(temp!=0x0f)
{
switch(temp)
{
case 0x07: num="8"; break;
case 0x0b: num="9"; break;
case 0x0d: num="10"; break;
case 0x0e: num="11"; break;
}
}
}
P2=0xef;
temp=P2;
temp&=0x0f;
if(temp!=0x0f)
{
delay(50);
if(temp!=0x0f)
{
switch(temp)
{
&nb
相关文档:
格式: echo "\033[字背景颜色;字体颜色m字符串\033[0m"
例如:
echo "\033[41;36m something here \033[0m"
其中41的位置代表底色, 36的位置是代表字的颜色
那些ascii code 是对颜色调用的始末.
\033[ ; m …… \033[0m
字背景颜色范围:40----49
40:黑
41:深红
42:绿
43:黄色
44:蓝色
45:紫色
4 ......
Linux
下
C
开发——
gcc
,
gdb
的使用
作者:
zccst
我们学习的过程应该是一个积累的过程,有无到有,又少到多,而不能像下山的猴子。
9
月份的时候是第一次系统学习
gcc, gdb, makefile
(详见前面博客)。如今作为嵌入式系统的一个组成部分,决定重学一次,感觉理解加深了一些。
gcc
......
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main(){
int sockfd;
int len;
struct sockaddr_in address;
int result;
char *strings="GET /svnup/rewrite.php HTTP/1 ......
6.1 编写一个程序,创建一个具有26个元素的数组,并在其中存储26个小写字母,并让该程序显示该数组的内容.
#include <stdio.h>
int main(void)
{
char a[26] = {'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l',
'm', 'n', 'o', 'p ......
wchar_t wsWorkingDir[256] = _T("");
CString strPDF(_T(""));
::GetCurrentDirectory(256, wsWorkingDir);
strPDF.Format(_T("%s"), wsWorkingDir);
if (strPDF.GetAt(strPDF.GetLength()-1) != '\\')
{
strPDF += '\\';
}
strPDF += "doc\\my.pdf" ......