给闺女做的流水灯
本帖最后由 弘毅 于 2012-12-18 23:29 编辑昨天拿到的nuo R3版,按照惯例淘宝搞定,45元,昨天半夜用IDE中的blink测试了一下板子,好用。今天承诺闺女做个流水灯,刚拿到硬件,一定不熟悉于是去官网搜了一下,找到了下面这个example(http://arduino.cc/en/Tutorial/BarGraph),于是依葫芦画瓢,接好硬件,没找到220Ω的电阻,就用了240Ω的,不大点事,代码直接把官网的复制过来,修改了一下,最终效果就是从左到右每隔500毫秒点亮一个灯,全部点亮后,从右到左每隔500毫秒依次熄灭,如此循环,闺女(2岁10个月)看了还挺感兴趣,不过没一会儿就拿着杜邦线忘面包板上乱插一气,俺的心哇凉啊,O(∩_∩)O~
-------------------------------------下面是代码-----------------------------
const int ledCount = 10; // the number of LEDs in the bar graph
int ledPins[] = {2, 3, 4, 5, 6, 7,8,9,10,11 }; // an array of pin numbers to which LEDs are attached
void setup()
{
// loop over the pin array and set them all to output:
for (int thisLed = 0; thisLed < ledCount; thisLed++)
{
pinMode(ledPins, OUTPUT);
}
}
int ledIndex=0;
boolean flag=true;
void loop()
{
//turn on all pins
for (int i=0;i<ledCount;i++)
{
digitalWrite(ledPins, HIGH);
delay(500);
}
// turn off all pins
for (int i=ledCount-1;i>=0;i--)
{
digitalWrite(ledPins, LOW);
delay(500);
}
}
----------------------------------代码结束---------------------------------------
效果图片:
:lol:lol;P 没其他配件?45元?哪家买的? 现在的UNO越来越不值钱了!!! 想问一下boolean flag=true;这句赋值了,后面却没有使用是闹哪样? 幸福的闺女儿 wangtianhuo 发表于 2012-12-19 09:42 static/image/common/back.gif
想问一下boolean flag=true;这句赋值了,后面却没有使用是闹哪样?
真不好意思,这句代码忘记注释掉了,本来是想作为正向点亮和反向点亮的标志。您看帖太仔细了,O(∩_∩)O~ xiaoaiwhc 发表于 2012-12-19 08:51 static/image/common/back.gif
没其他配件?45元?哪家买的?
给你消息了,免得广告,O(∩_∩)O~
这个板子不知道是不是仿得,我看那个usb芯片是atmel的
页:
[1]