Arduino例程解读与实验2. Blink(灯光闪烁)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_42948798/article/details/83818398

Arduino例程解读与实验2. Blink(灯光闪烁)

一、例程解读
/*
Blink//灯光闪烁

Turns an LED on for one second, then off for one second, repeatedly.
//发光二极管间隔1秒亮灭一次
Most Arduinos have an on-board LED you can control. //大多数Arduino开发板上都有一个板载LED,你可以控制它的亮灭
On the UNO, MEGA and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
the correct LED pin independent of which board is used.//该LED在UNO, MEGA and ZERO 开发板上连接在13脚,在MKR1000为第6脚。LED_BUILTIN设置在开发板独立的LED脚上,可直接使用
If you want to know what pin the on-board LED is connected to on your Arduino
model, check the Technical Specs of your board at://详情点击
https://www.arduino.cc/en/Main/Products

modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman

This example code is in the public domain.
//例程可到下面的公共链接下载。
http://www.arduino.cc/en/Tutorial/Blink
*/

// the setup function runs once when you press reset or power the board
//按下复位键后setup()只运行一次
void setup() {
// initialize digital pin LED_BUILTIN as an output.
//把LED_BUILTIN设为输出
pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
//loop()为无限循环
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
// turn the LED on (HIGH is the voltage level)
//LED_BUILTIN置高电平(LED亮)
delay(1000); // wait for a second//延迟一秒
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
//LED_BUILTIN置低电平(LED灭)
//wait for a second//延迟一秒
}
二、实验
1.下载程序
2.观察L灯
灯亮
灯灭

猜你喜欢

转载自blog.csdn.net/weixin_42948798/article/details/83818398