先说一下废话,知道arduino是在淘宝上买电子元件的时候了解的,顺手百度了一下,发现这个东东挺好玩,于是果断入手,为了给闺女(2岁10个月,O(∩_∩)O~)做点稍微高科技的玩意,今天刚收到货,49元一块,R3版,今天晚刚折腾好电脑,顺手就验一下板子怎么样,首先感谢一下“跟珜羽一起学Arduino NO.1 认识硬件以及连接”这一系列教程,俺暂时看了前两部分,今晚上的实验就是用的教程里说的“Blink”,然后自己动手改了一下,板子挺好用,下面附上测试代码(俺的第一份Arduino代码)。
---------------------------------------------代码--------------------------------------------------------------------------------
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
int blinkTime=0;//定义了一个闪烁次数
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
if (blinkTime<100)//闪完100次,灯改为长亮
{
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second,这里修改了闪烁频率
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
blinkTime++;
}
else
{
digitalWrite(led, HIGH);
}
}
-------------------------------------------------------代码结束-----------------------------------------------
最后顺便问一下,“Arduino”怎么发音啊,俺都是念“阿丢闹”,请各位指点。
新人第一次发帖,多多支持。
|