/*
Blink
Turns an LED on for one second, then off for one second, repeatedly.
*/
// define variables here
// variables should be defined before setup()
// You must include void setup() and void loop() in every Arduino sketch, or the program won\'t compile!
// the setup function runs once when you press reset or power the board
// setup()函数只运行一次,用来启动Arduino控制器,将运行中不改变的数值和属性固化到芯片中
void setup() {
// initialize digital pin LED_BUILTIN as an output.
// pinMode(pin,mode):将指定的引脚配置为输入或输出
//
- pin:所需要设置的引脚号
//
- mode:INPUT/OUTPUT(pinMode也可以是INPUT_PULLUP,使用引脚内置的上拉电阻)
pinMode(LED_BUILTIN, OUTPUT);
}
// loop()函数循环执行,直到按下reset键或者移除电源
void loop() {
// digitalWrite(pin,HIGH/LOW):数字引脚输出,HIGH表示高电平(5v),LOW表示低电平(0v)
// delay(num):暂停执行程序num毫秒
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000);
// wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000);
// wait for a second
}
【Arduino学习笔记02】第一个Arduino项目——点亮LED Blink.ino程序解读 Arduino程序基本结构 pinMode() digitalWrite() delay()
内容版权声明:除非注明,否则皆为本站原创文章。