導航:首頁 > 操作系統 > 單片機發送接收波形

單片機發送接收波形

發布時間: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];

}

閱讀全文

與單片機發送接收波形相關的資料

熱點內容
可以搜簡便演算法的軟體 瀏覽:198
各種的解壓小玩具 瀏覽:933
百度雲伺服器bcc域名綁定 瀏覽:486
android網路mp3格式 瀏覽:321
程序員抱怨it氣氛 瀏覽:698
改apk伺服器地址 瀏覽:414
原理圖中的編譯 瀏覽:924
繽智怎麼給車機安裝app 瀏覽:728
伺服器的證件是什麼 瀏覽:538
linuxgraphics 瀏覽:137
ACPI編譯工具MaciASL 瀏覽:895
導線點加密技巧 瀏覽:103
閃迪加密軟體如何去除 瀏覽:560
格力壓縮機技術 瀏覽:7
app下單約妹子的什麼語音 瀏覽:834
華為軟體加密怎麼關閉 瀏覽:325
安卓手機q系統怎麼用 瀏覽:105
一個淡定的程序員 瀏覽:423
怎麼在dos窗口打開python 瀏覽:591
怎麼通過網頁取伺服器ip 瀏覽:789