ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Arduino学习笔记---Blink

2022-02-03 20:33:23  阅读:203  来源: 互联网

标签:HIGH LED pin Arduino Blink --- BUILTIN board


Arduino学习笔记---Blink

Blink 应该是最简单的程序了

来自Arduino官网

 1 /*
 2   Blink
 3 
 4   Turns an LED on for one second, then off for one second, repeatedly.
 5 
 6   Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
 7   it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
 8   the correct LED pin independent of which board is used.
 9   If you want to know what pin the on-board LED is connected to on your Arduino
10   model, check the Technical Specs of your board at:
11   https://www.arduino.cc/en/Main/Products
12 
13   modified 8 May 2014
14   by Scott Fitzgerald
15   modified 2 Sep 2016
16   by Arturo Guadalupi
17   modified 8 Sep 2016
18   by Colby Newman
19 
20   This example code is in the public domain.
21 
22   https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
23 */
24 
25 // the setup function runs once when you press reset or power the board
26 void setup() {
27   // initialize digital pin LED_BUILTIN as an output.
28   pinMode(LED_BUILTIN, OUTPUT);
29 }
30 
31 // the loop function runs over and over again forever
32 void loop() {
33   digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
34   delay(100);                       // wait for a second
35   digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
36   delay(100);                       // wait for a second
37 }

 

主要由两个函数组成:setup() 和 loop()

setup() 只在程序开始时运行一次

loop() 接下来一直运行

几个函数

 

pinMode( pin, INPUT / OUTPUT ) 设置接口的模式

digitalWrite( pin , HIGH / LOW )

在接口写入数字信号:高/低电平

HIGH / LOW 也可以写为 1 / 0

LED_BUILTIN 在这块板上默认是 13 号口

delay (ms) 延时,占用系统资源

标签:HIGH,LED,pin,Arduino,Blink,---,BUILTIN,board
来源: https://www.cnblogs.com/liankewei/p/15861942.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有