在void setup 中先初始化一下红绿灯的状态你可以试试把红灯和绿灯的线相互调换一下。
这种和硬件强相关的东西别人看程序基本上不可能找到原因需要你自己把程序拆开一部分一部分调试了
可以用pwm也就是用模拟输出analogWrite(pin,vol);用循环语句将vol的值逐渐增大再逐渐减小就是呼吸灯了加入适当的延时
如果非要实时的话,你需要加入一个中断,用一个按键触发这个中断,然后在这个中断里写入你希望的状态,退出中断的时候再恢复现场
145 浏览 5 回答
233 浏览 4 回答
252 浏览 4 回答
356 浏览 4 回答
192 浏览 4 回答
304 浏览 5 回答
108 浏览 4 回答
119 浏览 5 回答
139 浏览 3 回答
322 浏览 5 回答
316 浏览 4 回答
244 浏览 4 回答
81 浏览 3 回答
347 浏览 5 回答
203 浏览 5 回答
225 浏览 3 回答
207 浏览 2 回答
294 浏览 5 回答
87 浏览 4 回答
307 浏览 2 回答
235 浏览 3 回答
327 浏览 3 回答
209 浏览 3 回答
339 浏览 5 回答
312 浏览 6 回答