📄 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 + -