|
各位大神,这样的描述对不对,总感觉怪怪的,感谢指点一下.
- #inclde"STC8GXXXX.H"
- sbit P1^1=LED; 灯具
- sbit P1^2=SW; 开关
-
- void main()
- {
- P0M0 = 0x00; P0M1 = 0x00;
- P1M0 = 0x00; P1M1 = 0x00;
- P2M0 = 0x00; P2M1 = 0x00;
- P3M0 = 0x00; P3M1 = 0x00;
- P4M0 = 0x00; P4M1 = 0x00;
- P5M0 = 0x00; P5M1 = 0x00;
- P6M0 = 0x00; P6M1 = 0x00;
- P7M0 = 0x00; P7M1 = 0x00;
-
-
-
- while (1)
- {
- if (LED == 0xff) // 灯亮时,开关关闭
- {
- SW = 0x00; // 设置P5口输出为高电平
- }
- else
- {
- LED = 0x00; // 灯不亮
- SW =0xff; // 开关开启
- }
-
- 。。。。。
-
- switch(num)
- {
- case 1:SW=~SW;LED=~LED;break;
- case 2:;break;
- case 3:;break;
- case 4:;break;
- case 5:;break;
- }
- }
复制代码
|
|