学习Arduino:初探 Ethernet Shield (以太网盾板)
2013-07-16
以太网盾板的使用说明: 配合Arduino网络扩展板,使用这个库可以让Arduino板连接到互联网。阅读全文
SAE:今天测试并完成了 WordPress 3.5.2 for SAE
2013-07-11
在完善了最后一点修复顶部图片支持裁剪功能后,WordPress 3.5.x 系列终于可以完整的运行在阅读全文
学习Arduino:红绿灯实验(自编)
2013-07-07
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
<span style="color: #cc6600;">int</span> potpin=0; <span style="color: #cc6600;">int</span> ledpin_red=9; <span style="color: #cc6600;">int</span> ledpin_yellow=10; <span style="color: #cc6600;">int</span> ledpin_green=11; <span style="color: #cc6600;">int</span> val=0; <span style="color: #cc6600;">void</span> <span style="color: #cc6600;"><b>setup</b></span>() { <span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">begin</span>(9600);<span style="color: #7e7e7e;">//设置波特率为9600</span> <span style="color: #cc6600;">pinMode</span>(ledpin_red,<span style="color: #006699;">OUTPUT</span>); <span style="color: #cc6600;">pinMode</span>(ledpin_yellow,<span style="color: #006699;">OUTPUT</span>); <span style="color: #cc6600;">pinMode</span>(ledpin_green,<span style="color: #006699;">OUTPUT</span>); <span style="color: #7e7e7e;">//注意:模拟接口自动设置为输入</span> } <span style="color: #cc6600;">void</span> <span style="color: #cc6600;"><b>loop</b></span>() { val=<span style="color: #cc6600;">analogRead</span>(potpin);<span style="color: #7e7e7e;">// 读取传感器的模拟值并赋值给val</span> <span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>(val);<span style="color: #7e7e7e;">//显示val 变量</span> <span style="color: #7e7e7e;">//红灯</span> <span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>(<span style="color: #006699;">"Red! STOP!!!!!"</span>); <span style="color: #cc6600;">analogWrite</span>(ledpin_red,val/4);<span style="color: #7e7e7e;">//红灯亮,绿灯和黄灯灭</span> <span style="color: #cc6600;">analogWrite</span>(ledpin_green,<span style="color: #006699;">LOW</span>); <span style="color: #cc6600;">analogWrite</span>(ledpin_yellow,<span style="color: #006699;">LOW</span>); <span style="color: #cc6600;">delay</span>(5000);<span style="color: #7e7e7e;">//延时5秒</span> <span style="color: #7e7e7e;">//黄灯变换</span> <span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>(<span style="color: #006699;">"Notice!SLOW DOWN!!! Yellow!"</span>); <span style="color: #cc6600;">analogWrite</span>(ledpin_yellow,val/4); <span style="color: #cc6600;">delay</span>(500); <span style="color: #cc6600;">analogWrite</span>(ledpin_yellow,<span style="color: #006699;">LOW</span>); <span style="color: #cc6600;">delay</span>(500); <span style="color: #cc6600;">analogWrite</span>(ledpin_yellow,val/4); <span style="color: #cc6600;">delay</span>(500); <span style="color: #cc6600;">analogWrite</span>(ledpin_yellow,<span style="color: #006699;">LOW</span>); <span style="color: #cc6600;">delay</span>(500); <span style="color: #cc6600;">analogWrite</span>(ledpin_yellow,val/4); <span style="color: #cc6600;">delay</span>(500);<span style="color: #7e7e7e;">//黄灯闪烁三次,此时红灯仍是亮的</span> <span style="color: #7e7e7e;">//绿灯</span> <span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>(<span style="color: #006699;">"GREEN! GOGOGO!"</span>); <span style="color: #cc6600;">analogWrite</span>(ledpin_green,val/4);<span style="color: #cc6600;">analogWrite</span>(ledpin_red,val/4);<span style="color: #7e7e7e;">//绿灯亮,红灯和黄灯灭</span> <span style="color: #cc6600;">analogWrite</span>(ledpin_red,<span style="color: #006699;">LOW</span>); <span style="color: #cc6600;">analogWrite</span>(ledpin_yellow,<span style="color: #006699;">LOW</span>); <span style="color: #cc6600;">delay</span>(5000);<span style="color: #7e7e7e;">//延时5秒</span> <span style="color: #7e7e7e;">//变换,完全复制上面的</span> <span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>(<span style="color: #006699;">"Notice! Yellow!"</span>); <span style="color: #cc6600;">analogWrite</span>(ledpin_yellow,val/4); <span style="color: #cc6600;">delay</span>(500); <span style="color: #cc6600;">analogWrite</span>(ledpin_yellow,<span style="color: #006699;">LOW</span>); <span style="color: #cc6600;">delay</span>(500); <span style="color: #cc6600;">analogWrite</span>(ledpin_yellow,val/4); <span style="color: #cc6600;">delay</span>(500); <span style="color: #cc6600;">analogWrite</span>(ledpin_yellow,<span style="color: #006699;">LOW</span>); <span style="color: #cc6600;">delay</span>(500); <span style="color: #cc6600;">analogWrite</span>(ledpin_yellow,val/4); <span style="color: #cc6600;">delay</span>(500);<span style="color: #7e7e7e;">//闪烁三次</span> } |
效果:阅读全文
WordPress技术:如何在WordPress中在线运行/执行代码
2013-07-05
有时候我们想在页面内运行代码,方便说明问题,类似于 w3school 那样的。 实现方法可以分为插件阅读全文
学习Arduino:至今天学完了翁恺老师的 Arduino 初级课程
2013-07-03
这个老师讲课果然让人喜欢。 这是一个关于 Arduino 的初级课程,面向的对象是没有什么编程基础的阅读全文
学习Arduino:Arduino创始人亲自操刀–Arduino入门套件系列视频教程[转载]
2013-07-01
转载自:EEboard爱板网 Arduino是一个开放源码的电子原型平台,基于灵活易用的硬件和软件开阅读全文