导航:首页 > 操作系统 > 单片机发送接收波形

单片机发送接收波形

发布时间:2024-06-29 13:55:28

① C51的单片机做红外空调编码发送的问题 就是现在单片机发送的波形和空调遥控器发送的波形基本上是一样的

是38KHZ的载波频率,占空比1/3,一般正负1kHZ没什么问题。
首先你要先确定空调是采用什么编码格式,(现在常用的是NEC,飞利浦等编码格式)。然后还要确定空调接收的按键键值(数据)所执行的功能,编码格式很重要,不然空调是接受不到按键键值(数据)的,注意发送的数据是要加到载波上面去。

② 基于单片机的信号发生器波形是怎么产生的

状态机方法,可以输出任意时序,最近在做cpu,给你段cpu的时钟发生器的程序。
部分程序,表达意思。
always @(negedge clk)
begin
case(state)
S1:
begin
clk2 <= ~clk2;
alu_clk <= ~alu_clk;
state <= S2;
end
S2:
begin
clk2 <= ~clk2;
clk3 <= ~clk3;
alu_clk <= ~alu_clk;
state <= S3;
fetch <= ~fetch;
end
S3:
begin
clk2 <= ~clk2;
state <= S4;

end
S4:
begin
clk2 <= ~clk2;
clk3 <= ~clk3;

state <= S5;
end
。。。。
default:
state <= idle;
endcase
end
endmole

③ 单片机8051设计简易波形发生器,要求能产生正弦波,方波,三角波,通过键盘可改变输出信号的频率和幅度

这个网上资料很多的,你可以参考下的,我前几天也做了个,proteus仿真的,程序如下,希望能帮到你的,有问题可以交流下的
#include<reg51.h>

unsigned char i,sqar_num=128; //最大值100,默认值50
unsigned char cho=0; //0:正弦波。1:方波。2:三角波。3:锯齿波。
unsigned char num=0;
unsigned char TIME0_H=0xff,TIME0_L=0xdc; //定时器0的初值设置;全局变量.对应正弦波,锯齿波50HZ
sbit chg= P1^0;
sbit freq_u=P1^1;
sbit freq_d=P1^2;
sbit ty_u=P1^3;
sbit ty_d=P1^4;
sbit cs =P3^7;
bit flag=0;
unsigned int FREQ=50;//初始化频率,30HZ
unsigned char flag1;

sbit rs=P1^5;
sbit lcdcs=P1^7;
sbit cd=P3^0;
unsigned char TempBuffer[7];

unsigned char value1[]={"Frequency:"};

void delay(unsigned int ms)
{
unsigned int i,j;
for (j=0;j<ms;j++)
for (i=0;i<120;i++);
}

unsigned char code sin_num[]={
0x80,0x82,0x85,0x88,0x8b,0x8e,0x91,0x94,0x97,0x9a,0x9d,0xa0,0xa3,0xa6,
0xa9,0xac,0xaf,0xb2,0xb6,0xb9,0xbc,0xbf,0xc2,0xc5,0xc7,0xca,0xcc,0xcf,
0xd1,0xd4,0xd6,0xd8,0xda,0xdd,0xdf,0xe1,0xe3,0xe5,0xe7,0xe9,0xea,0xec,
0xee,0xef,0xf1,0xf2,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,
0xfd,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xfe,0xfd,0xfd,0xfc,0xfb,0xfa,0xf9,0xf8,0xf7,0xf6,0xf5,0xf4,0xf2,0xf1,
0xef,0xee,0xec,0xea,0xe9,0xe7,0xe5,0xe3,0xe1,0xde,0xdd,0xda,0xd8,0xd6,
0xd4,0xd1,0xcf,0xcc,0xca,0xc7,0xc5,0xc2,0xbf,0xbc,0xba,0xb7,0xb4,0xb1,
0xae,0xab,0xa8,0xa5,0xa2,0x9f,0x9c,0x99,0x96,0x93,0x90,0x8d,0x89,0x86,
0x83,0x80,
0x80,0x7c,0x79,0x76,0x72,0x6f,0x6c,0x69,0x66,0x63,0x60,0x5d,
0x5a,0x57,0x55,0x51,0x4e,0x4c,0x48,0x45,0x43,0x40,0x3d,0x3a,0x38,0x35,
0x33,0x30,0x2e,0x2b,0x29,0x27,0x25,0x22,0x20,0x1e,0x1c,0x1a,0x18,0x16,
0x15,0x13,0x11,0x10,0x0e,0x0d,0x0b,0x0a,0x09,0x08,0x07,0x06,0x05,0x04,
0x03,0x02,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x02,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,
0x0d,0x0e,0x10,0x11,0x13,0x15,0x16,0x18,0x1a,0x1c,0x1e,0x20,0x22,0x25,
0x27,0x29,0x2b,0x2e,0x30,0x33,0x35,0x38,0x3a,0x3d,0x40,0x43,0x45,0x48,
0x4c,0x4e,0x51,0x55,0x57,0x5a,0x5d,0x60,0x63,0x66,0x69,0x6c,0x6f,0x72,
0x76,0x79,0x7c,0x80
/* 135,145,158,167,176,188,199,209,218,226,234,240,245,249,252,254,254,253,251,247,243,237,230,222,213,204,193,182,170,158,
146,133,121,108,96,84,72,61,50,41,32,24,17,11,7,3,1,0,0,2,5,9,14,20,28,36,45,55,66,78,90,102,114,128
*/
};
unsigned code sanjiao_num[]=
{
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,
36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,
70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,
104,106,108,110,112,114,116,118,120,122,124,126,128,130,
132,134,136,138,140,142,144,146,148,150,152,154,158,160,162,164,166,168,170,
172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,
212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,
252,254,255,254,252,250,248,246,244,242,240,238,236,234,232,230,228,226,224,222,220,
218,216,214,212,210,208,206,204,202,200,198,196,194,192,190,188,186,184,182,180,178,
176,174,172,170,168,166,164,162,160,158,154,152,150,148,146,144, 142,140,138,136,134,
132,130,128,126,124,122,120,118,116,114,112,110,108,106,104,102,100,98,96,94,92,90,88,
86,84,82,80,78,76,74,72,70,68,66,64,62,60,58,56,54,52,50,48,46,44,42,40,38,36,
34,32,30,28,26,24,22,20,18,16,14,12,10,8,6,4,2,0,

};

//调节部分——频率
void freq_ud(void)
{
unsigned int temp;
if(freq_d==0)
{ FREQ--; }
else if(freq_u==0)
{ FREQ++; }
temp=0xffff-3906/FREQ; //切换后频率为50HZ 65336-10^6/(256*FREQ)
// temp=0xffff-1953/FREQ;
TIME0_H=temp/256;
TIME0_L=temp%256;

}
//调节部分——方波的占空比
void ty_ud(void) //方波也采用512次中断构成一个周期。
{
if(ty_d==0&sqar_num>0)
sqar_num--;
else if(ty_u==0&sqar_num<255)
sqar_num++;

}
//波形发生函数
void sint(void)
{
// char num=0;
// if(!flag)
{
cs=0;P2=sin_num[num++];cs=1;
if(num==255){num=0;}
}
/* else if(flag)
{
cs=0;P2=sin_num[num--];cs=1;
if(num==0){num=0;flag=0;}

} */
}

void square(void)
{
if(i++<sqar_num) {cs=0;P2=0XFF;cs=1;}
else{cs=0;P2=0X00;cs=1;}
}
void triangle(void)
{
cs=0;P2=num++;cs=1;
}
void stw(void)
{
cs=0;P2=sanjiao_num[num++];cs=1;
if(num==255){num=0;flag=1;}
}

//1602显示开始
void write_command(unsigned char command)
{
rs=0;
P0=command;
lcdcs=1;
lcdcs=0;
}

void write_data(unsigned char data0)
{
rs=1;
P0=data0;
lcdcs=1;
lcdcs=0;
}

void init_1602()
{
delay(1);
write_command(0x38);
delay(1);
write_command(0x0c);
delay(1);
write_command(0x06);
delay(1);
}
//1602显示结束

/*******************频率值转换为字符串**********************/
void temp_to_str()
{

TempBuffer[0]=FREQ/1000+'0'; //千位
TempBuffer[1]=FREQ%1000/100+'0'; //百位
TempBuffer[2]=FREQ%1000%100/10+'0';//十位
TempBuffer[3]=FREQ%1000%100%10+'0';//个位
TempBuffer[4]='H';
TempBuffer[5]='Z';
TempBuffer[6]='\0';
}
void main()
{
TMOD=0X01;
TH0=0xff;
TL0=0xd9;
IT0=1; //设置中断触发方式,下降沿
EA=1;
EX0=1;
ET0=1;
IP=0X01; //键盘中断级别高
init_1602();//初始化lcd
write_command(0x80);//液晶显示位置
delay(1);
for (i=0;i<sizeof(value1)-1;i++)
{
write_data(value1[i]);
delay(1);
}

TR0=1;
while(1)
{
show_frequency();
}
}

④ 如何编写安卓程序接收单片机WiFi模块发送的信号,并画出信号的波形

android获取wifi的信息:
WifiManager wifi_service = (WifiManager)getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifi_service.getConnectionInfo();

其中WifiManager是管理wifi的最重要的类,详细请参考
http://developer.android.com/reference/android/net/wifi/WifiManager.html
其中wifiInfo有以下的方法:
wifiinfo.getBSSID();
wifiinfo.getSSID();
wifiinfo.getIpAddress();获取IP地址。
wifiinfo.getMacAddress();获取MAC地址。
wifiinfo.getNetworkId();获取网络ID。
wifiinfo.getLinkSpeed();获取连接速度,可以让用户获知这一信息。
wifiinfo.getRssi();获取RSSI,RSSI就是接受信号强度指示。在这可以直 接和华为提供的Wi-Fi信号阈值进行比较来提供给用户,让用户对网络或地理位置做出调整来获得最好的连接效果。
这里得到信号强度就靠wifiinfo.getRssi();这个方法。得到的值是一个0到-100的区间值,是一个int型数据,其中0到-50表示信号最好,-50到-70表示信号偏差,小于-70表示最差,有可能连接不上或者掉线,一般Wifi已断则值为-200。

⑤ 怎么用单片机实现一个特定的波形,波形如下

上升沿和下降沿的时间也有要求吗?
如果没有要求就好办!
用一个单片机的I/O口上下各拉一个相同阻值的电阻
1.IO设为输入
2.延时,
3.I/O设置为输出,输出高
4.延时,
5.I/O设为输入
6.延时
7.I/O设置为输出,输出高
8.延时
8.I/O设置为输出,输出底
9.延时
1-9步循环输出就是所要波形了

1.如果上升和下降沿时间都有要求,要产生如果后面那个波形那样相同时间上升下降沿的斜边,那就上面的方法不行,就得用D/A转换才能产生。
2.如果对波形的幅值有所要求,上面的方法也不行,也只能用D/A转换才能产生。
3.上面的方法只能产生5V 1/2的偏压,因为单片机I/O口输出是5V的,即产生0V,+5V和-5V

⑥ 如何运用单片机原理制作智能信号发生器,要求产生方波、矩形波、三角波、锯齿波和正弦波。

#include<reg51.h>

#include<absacc.h>

#include<MAX72191.h>

#defineDAC XBYTE[0x7fff] //P2.7接CS

sbitkey0 = P3^2;// 增减切换键

sbitkey1 = P3^3;//个位,十位,百位,千位的控制切换

sbitkey2 = P3^4;// 调整位

sbitkey3 = P3^5;// 波形选择正弦、三角、矩形波,锯齿波

unsignedchar i,j;

unsignedint counter,step,flag;

typedefunsigned int uint;

//定时器0初始化

voidInit_Timer0(void)

{

TMOD = (TMOD & 0XF0) | 0X01;//设置工作方式和定时初始值

TH0 = 0xff;

TL0 = 0x00;

TR0 =1; //启动定时器

ET0 =1;

}

//定义输出波形的代码

unsignedchar code type[4][256]={

{ //正弦波代码

0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x1, 0x1, 0x2, 0x3, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8,

0x9, 0xb,0xc, 0xd, 0xf, 0x10,0x12,0x13,0x15,0x17,0x19,0x1b,0x1d,0x1f,0x21,0x23,

0x25,0x27,0x2a,0x2c,0x2e,0x31,0x33,0x36,0x39,0x3b,0x3e,0x41,0x43,0x46,0x49,0x4c,

0x4f,0x52,0x55,0x58,0x5b,0x5e,0x61,0x64,0x67,0x6a,0x6d,0x70,0x73,0x76,0x7a,0x7d,

0x80,0x83,0x86,0x89,0x8c,0x8f,0x93,0x96,0x99,0x9c,0x9f,0xa2,0xa5,0xa8,0xab,0xae,

0xb1,0xb4,0xb6,0xb9,0xbc,0xbf,0xc1,0xc4,0xc7,0xc9,0xcc,0xce,0xd1,0xd3,0xd5,0xd8,

0xda,0xdc,0xde,0xe0,0xe2,0xe4,0xe6,0xe8,0xea,0xeb,0xed,0xef,0xf0,0xf1,0xf3,0xf4,

0xf5,0xf6,0xf8,0xf9,0xf9,0xfa,0xfb,0xfc,0xfc,0xfd,0xfd,0xfe,0xfe,0xfe,0xfe,0xfe,

0xfe,0xfe,0xfe,0xfe,0xfe,0xfd,0xfd,0xfc,0xfc,0xfb,0xfa,0xf9,0xf9,0xf8,0xf6,0xf5,

0xf4,0xf3,0xf1,0xf0,0xef,0xed,0xeb,0xea,0xe8,0xe6,0xe4,0xe2,0xe0,0xde,0xdc,0xda,

0xd8,0xd5,0xd3,0xd1,0xce,0xcc,0xc9,0xc7,0xc4,0xc1,0xbf,0xbc,0xb9,0xb6,0xb4,0xb1,

0xae,0xab,0xa8,0xa5,0xa2,0x9f,0x9c,0x99,0x96,0x93,0x8f,0x8c,0x89,0x86,0x83,0x80,

0x7d,0x7a,0x76,0x73,0x70,0x6d,0x6a,0x67,0x64,0x61,0x5e,0x5b,0x58,0x55,0x52,0x4f,

0x4c,0x49,0x46,0x43,0x41,0x3e,0x3b,0x39,0x36,0x33,0x31,0x2e,0x2c,0x2a,0x27,0x25,

0x23,0x21,0x1f,0x1d,0x1b,0x19,0x17,0x15,0x13,0x12,0x10,0xf,0xd, 0xc, 0xb, 0x9,

0x8,0x7, 0x6, 0x5, 0x4, 0x3, 0x3, 0x2, 0x1, 0x1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

},

{ //三角波代码

0x2,0x4, 0x6, 0x8, 0xa, 0xc, 0xe, 0x10,0x12,0x14, 0x16, 0x18, 0x1a,0x1c, 0x1e, 0x20,

0x22,0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30,0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e, 0x40,

0x42,0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50,0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e, 0x60,

0x62,0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70,0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e, 0x80,

0x82,0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90,0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e, 0xa0,

0xa2,0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0,0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc,0xbe, 0xc0,

0xc2,0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0,0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc,0xde, 0xe0,

0xe2,0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0,0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc,0xfe, 0xff,

0xfe,0xfc, 0xfa, 0xf8, 0xf6, 0xf4, 0xf2, 0xf0,0xee, 0xec, 0xea, 0xe8, 0xe6, 0xe4,0xe2, 0xe0,

0xde,0xdc, 0xda, 0xd8, 0xd6, 0xd4, 0xd2, 0xd0,0xce, 0xcc, 0xca, 0xc8, 0xc6, 0xc4,0xc2, 0xc0,

0xbe,0xbc, 0xba, 0xb8, 0xb6, 0xb4, 0xb2, 0xb0,0xae, 0xac, 0xaa, 0xa8, 0xa6, 0xa4,0xa2, 0xa0,

0x9e, 0x9c, 0x9a, 0x98, 0x96, 0x94, 0x92, 0x90,0x8e, 0x8c, 0x8a, 0x88, 0x86, 0x84, 0x82, 0x80,

0x7e, 0x7c, 0x7a, 0x78, 0x76, 0x74, 0x72, 0x70,0x6e, 0x6c, 0x6a, 0x68, 0x66, 0x64, 0x62, 0x60,

0x5e, 0x5c, 0x5a, 0x58, 0x56, 0x54, 0x52, 0x50,0x4e, 0x4c, 0x4a, 0x48, 0x46, 0x44, 0x42, 0x40,

0x3e, 0x3c, 0x3a, 0x38, 0x36, 0x34, 0x32, 0x30,0x2e, 0x2c, 0x2a, 0x28, 0x26, 0x24, 0x22, 0x20,

0x1e, 0x1c, 0x1a, 0x18, 0x16, 0x14, 0x12, 0x10,0xe, 0xc,0xa, 0x8, 0x6,0x4, 0x2, 0x00

},

{// 矩形脉冲波代码

0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff,

0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff,

0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff,

0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff,

0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff,

0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff,

0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff,

0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff,

0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,

0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,

0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,

0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,

0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,

0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,

0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,

0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,

},

{//锯齿波代码

0x00,0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,0x08,0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,

0x10,0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,0x18,0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,

0x20,0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,0x28,0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,

0x30,0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,0x38,0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,

0x40,0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,0x48,0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,

0x50,0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,0x58,0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,

0x60,0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,0x68,0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,

0x70,0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,0x78,0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,

0x80,0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,0x88,0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,

0x90,0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,0x98,0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,

0xa0,0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,0xa8,0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,

0xb0,0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,0xb8,0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,

0xc0,0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,0xc8,0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,

0xd0,0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,0xd8,0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,

0xe0,0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,0xe8,0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,

0xf0,0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,0xf8,0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff}

};

//显示子函数

Disp7219(unsignedlong dat)

{

unsigned char i;

unsigned char led[8];

led[7]=dat%10;

led[6]=dat/10%10;

led[5]=dat/100%10;

led[4]=dat/1000%10;

led[3]=dat/10000%10;

led[2]=dat/100000%10;

led[1]=dat/1000000%10;

led[0]=dat/10000000%10;

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

{

max_7219(i+1, led[i]);

}

}

//延时约1m秒

voiddelay_ms(uint n)

{

uchar j;

while(n--)

for(j=0;j<120;j++);

}

//主函数

main()

{

unsigned int f,n,j;

delay_ms(500);

Init_Max7219();//初始化7219

Disp7219(000);

Init_Timer0();

step=18;

EA = 1;

while(1)

{

if(key0 == 0) n=n+1;

if(n==2)n=0;

if(key1==0) j=j+1;

if(j==4) j=0;

if(n==0 && j == 0 &&key2 == 0) if(step<180) step+=18; //个位增

if(n==1 && j == 0 &&key2 == 0) if(step>18) step-=18; //个位减

if(n==0 && j == 1 &&key2 == 0) if(step<1800) step+=180;//十位增

if(n==1 && j == 1 &&key2 == 0) if(step>180) step-=180; //十位减

if(n==0 && j == 2 &&key2 == 0) if(step<18000) step+=1800;//百位增

if(n==1 && j == 2 &&key2 == 0) if(step>1800) step-=1800;//百位减

if(n==0 && j == 3 &&key2 == 0) if(step<54000) step+=18000;//千位增

if(n==1 && j == 3 &&key2 == 0) if(step>18000) step-=18000;//千位减

if(key3==0)flag=flag+1;if(flag==4)flag=0;

while((!key0)||(!key1)||(!key2)||(!key3));

f=step/18;

Disp7219(f);}//显示频率

}

// 定时中断服务

voidTimer0(void) interrupt 1 using 2

{

TH0 = 0xff;

TL0 = 0x00;

counter = counter + step;

DAC=type[flag][(unsignedint)counter>>8];

}

阅读全文

与单片机发送接收波形相关的资料

热点内容
程序员大爷采访 浏览:321
广联达算量怎么增加加密区 浏览:487
steam截屏图片默认文件夹 浏览:184
java环境变量设置mac 浏览:170
安卓如何传原图到ipad 浏览:850
命令方块手机版在哪里 浏览:145
po如何进去服务器 浏览:479
专门看美国剧情片网站 浏览:598
漏点的丧尸电影 浏览:864
html视频聊天源码 浏览:379
单片机网络运维 浏览:986
舌吻电影 浏览:453
单片机0ffh 浏览:405
机器人编程学习资料 浏览:149
被窝爱看大咖福利在线电影网 浏览:378
母乳汁理沦片 浏览:269
电子发票如何填写服务器地址 浏览:807
python主线程和子线程区别 浏览:531
看动画片的免费网站 浏览:39
五百里是哪部电影的主题曲 浏览:595