?? order.lst
字號:
1:
2:
3: //****************************************************************/
4: /*8路順序控制器源程序,源文件名order.c*/
5: //先順序點亮led0--led7,然后再反序點亮led7--led0
6: //****************************************************************/
7:
8: #include <pic.h>
9: #include <pic1687x.h>
10: #define PORTBIT(add,bit) ((unsigned)(&add)*8+(bit))
11:
12: static bit PORT_0 @ PORTBIT(PORTB,0); /*定義PORTB 0位*/
13: static bit PORT_1 @ PORTBIT(PORTB,1); /*定義PORTB 1位*/
14: static bit PORT_2 @ PORTBIT(PORTB,2); /*定義PORTB 2位*/
15: static bit PORT_3 @ PORTBIT(PORTB,3); /*定義PORTB 3位*/
16: static bit PORT_4 @ PORTBIT(PORTB,4); /*定義PORTB 4位*/
17: static bit PORT_5 @ PORTBIT(PORTB,5); /*定義PORTB 5位*/
18: static bit PORT_6 @ PORTBIT(PORTB,6); /*定義PORTB 6位*/
19: static bit PORT_7 @ PORTBIT(PORTB,7); /*定義PORTB 7位*/
20:
21: void delay(); //延遲函數的聲明
22:
23: main()
24: { TRISB=0x00; //設置portb口全為輸出
25: INTCON=0x00; //關閉所有的中斷
26: PORTB=0x00; //RB口先送低電品平
27:
28: loop1:
29: //點亮led的第0位,順序顯示
30: //PORTB=0x01;
31: PORT_0=1;
32: delay();
33:
34: //點亮led的第1位
35: //PORTB=0x03;
36: PORT_1=1;
37: delay();
38:
39: //點亮led的第2位
40: //PORTB=0x07;
41: PORT_2=1;
42: delay();
43:
44: //點亮led的第3位
45: //PORTB=0x0f;
46: PORT_3=1;
47: delay();
48:
49: //點亮led的第4位
50: //PORTB=0x1f;
51: PORT_4=1;
52: delay();
53:
54: //點亮led的第5位
55: //PORTB=0x3f;
56: PORT_5=1;
57: delay();
58:
59: //點亮led的第6位
60: //PORTB=0x7f;
61: PORT_6=1;
62: delay();
63:
64: //點亮led的第7位
65: //PORTB=0xff;
66: PORT_7=1;
67: delay();
68:
69: //全滅
70: PORTB=0x00;
71: delay();
72:
73: //點亮led的第7位,反序顯示
74: //PORTB=0x80;
75: PORT_7=1;
76: delay();
77:
78: //點亮led的第6位
79: //PORTB=0xc0;
80: PORT_6=1;
81: delay();
82:
83: //點亮led的第5位
84: //PORTB=0xe0;
85: PORT_5=1;
86: delay();
87:
88: //點亮led的第4位
89: //PORTB=0xf0;
90: PORT_4=1;
91: delay();
92:
93:
94: //點亮led的第3位
95: //PORTB=0xf8;
96: PORT_3=1;
97: delay();
98:
99: //點亮led的第2位
100: //PORTB=0xfc;
101: PORT_2=1;
102: delay();
103:
104: //點亮led的第1位
105: //PORTB=0xfe6;
106: PORT_1=1;
107: delay();
108:
109: //點亮led的第0位
110: //PORTB=0xff;
111: PORT_0=1;
112: delay();
113:
114: //全滅
115: PORTB=0x00;
116: delay();
117:
118: goto loop1;
119: }
120:
121: void delay()
122: {
123: int i;
124: for(i=0;i<=65;i++)
125: continue;
126:
127: }
128:
129:
130:
131:
132:
133:
134:
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -