单片机流水灯一个开关控制

#include #include #define uchar unsigned char sbit button = P3^2; uchar press = 0; uchar luishui = 0xfe; void Delay(uchar z) { uchar x, y; for(x = z; x > 0; x--) for(y = 255; y > 0; y--); } void main() { IT0 = 1; EX0 = 1; EA = 1; while(1) { if(press == 1) P0 = 0xff; if(press == 0) { P0 = luishui; luishui = _crol_(luishui, 1); Delay(255); } } } X0_INT() interrupt 0 { press += 1; if(press == 2) press = 0; Delay(10); while(button == 0); }

这个开关电路有问题,这样接的话需要加一个
下拉电阻
。而且还需要一个
限流电阻
温馨提示:答案为网友推荐,仅供参考
相似回答