Presentation is loading. Please wait.

Presentation is loading. Please wait.

程式設計期末測驗 通訊一甲 B09622048 楊穎穆.

Similar presentations


Presentation on theme: "程式設計期末測驗 通訊一甲 B09622048 楊穎穆."— Presentation transcript:

1 程式設計期末測驗 通訊一甲 B 楊穎穆

2 摘要 ※使用C語言設計程式,並將結果作成PPT檔及操作影音檔報告交出,報告必須包括:
a.問題分析:動作原理分析後用流程圖或演算法展示處理程序 b.程式必須加以註解 c.不能使用goto指令者 d.重複指令者只可以用for loop,while,do while指令 e.延時電路需要副程式完成

3 h.重複a工作 ※學號尾數為偶數號同學: a.P1接8顆LED初使全滅0.5秒然後全亮0.5秒 b.重複做a兩次然後做c工作
d.重複做c兩次然後做e工作 e.唱出Do,Me,Me,各0.5拍各一次 f.P3接開關輸入4BIT二進制 g.P2接共陽極七段顯示器顯示用查表法顯示開關輸入4BIT二進致對應的顯示數值,例0001對應1,1111對應F h.重複a工作

4 目錄 1.流程圖 2.程式 3.實驗結果 4.資料來源

5 a<=beat[i]*tow[i]*0.55;a++
流程圖 i=0;i<3 main P1 = 0xFF; i++ delay(25000); delay(x) a=0; a<=beat[i]*tow[i]*0.55;a++ X-->0 P1 = 0x00; P00=~P00; delay(25000); Bin2seg(x) delay(100000/tow[i]/2); P1 = 0x7F; P2=seg[x] delay(25000); b=P3&0x0F; return bin2seg(b);

6 程式 #include <reg51.h> #define Do 262*2 //Do頻率
#define Mi 330* //MI頻率 sbit P00=P0^0; //P00 = P00的第一隻Pin int delay(int); //宣告副程式 int code beat[3]={1,1,1}; //歌曲的拍子 int code tow[3]={Do,Mi,Mi}; //歌曲的音調 int i,a,b; //宣告變數 int bin2seg(int x); unsigned char code seg[16] =(0x81,0xCF,0x92,0x86,0xCC,0xA4,0xA0,0x8F,0x80,0x8C,0x88,0xE0,0xB1,0xC2,0xB0,0xB8); int main(void){ P00=1; while(1){

7 P1 = 0xFF; //遮默效果 delay(25000); //延遲0.5秒 P1 = 0x00; //全亮 delay(25000); //延遲0.5秒 P1 = 0xFF; delay(25000); P1 = 0x00; P1 = 0x7F; //右邊第一個燈亮 P1 = 0xBF; //第二個燈亮 P1 = 0xDF; P1 = 0xEF ; P1 = 0xF7; P1 = 0xFB; P1 = 0xFD; P1 = 0xFE;

8 P1 = 0x7F; delay(25000); P1 = 0xBF; P1 = 0xDF; P1 = 0xEF ; P1 = 0xF7; P1 = 0xFB; P1 = 0xFD; P1 = 0xFE; for(i=0;i<3;i++){ for(a=0;a<=beat[i]*tow[i]*0.55;a++){ //a從0到 Hz*0.55*拍子 P00=~P00; //P00 = P00的相反 delay(100000/tow[i]/2); //delay tone的時間 10萬/hz }

9 b=P3&0x0F; bin2seg(b); } int delay(int x){ //delay副程式 while(x>0); x--; int bin2seg(int x){ P2=seg[x]; return 0;

10 實驗結果 ※就會顯示出我們所要的。如下:

11 資料來源 ※主要來自王志湖老師上課所教授的內容及同學的指導。

12 END


Download ppt "程式設計期末測驗 通訊一甲 B09622048 楊穎穆."

Similar presentations


Ads by Google