arduino 不断的执行setup_Arduino单片机最少代码示例,少到超乎你的想像

Bare Minimum: 最小代码

The bare minimum of code needed to start an Arduino sketch.

启动Arduino项目所需的最低限度代码。

This example contains the bare minimum of code you need for a sketch to compile properly on Arduino Software (IDE): the setup() method and the loop() method.

此示例包含项目以在Arduino软件(IDE)上正确编译所需的最少代码:setup()方法和loop()方法。

  • Hardware Required所需硬件

Arduino or Genuino Board

Arduino或Genuino板

  • Circuit电路图

Only your Arduino or Genuino Board is needed for this example.

本示例仅需要您的Arduino或Genuino开发板。

5969879be57ed06f75b87ca90106d128.png

image developed using Fritzing. For more circuit examples, see the Fritzing project page

使用Fritzing开发的图像。有关更多电路示例,请参见Fritzing项目页面

  • Code 代码解析

The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using libraries, etc. The setup function will only run once, after each powerup or reset of the board.

setup()项目开始时调用该函数。用它来初始化变量,引脚模式,开始使用库等。在每次上电或复位板后,设置功能将只运行一次。

After creating a setup() function, the loop() function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond as it runs. Code in the loop() section of your sketch is used to actively control the board.

创建setup()函数后,loop()函数将(正如其名)执行并且连续循环,从而使您的程序在运行时可以进行更改和响应。loop()项目部分中的代码用于主动控制电路板。

The code below won't actually do anything, but it's structure is useful for copying and pasting to get you started on any sketch of your own. It also shows you how to make comments in your code.

下面的代码实际上不会做任何事情,但是它的结构对于复制和粘贴很有用,可帮助您开始编写自己的任何项目。它还显示了如何在代码中进行注释。

Any line that starts with two slashes (//) will not be read by the compiler, so you can write anything you want after it. The two slashes may be put after functional code to keep comments on the same line. Commenting your code like this can be particularly helpful in explaining, both to yourself and others, how your program functions step by step.

任何以两个斜杠(//)开头的行都不会被编译器读取,因此您可以在其后写任何内容。也可以将两个斜杠放在功能代码之后,让注释保持在同一行上。像这样注释您的代码对于向您自己和他人说明程序的每步的功能特别有用。

  • Code 代码示例

The bare minimum of code needed to start an Arduino sketch.

启动Arduino项目所需的最小代码。

1. void setup() {

2. // put your setup code here, to run once:把您的设置代码放置于此,它将运行一次。

3. }

4. void loop() {

5. // put your main code here, to run repeatedly:把您的主代码放置于此,它将循环运行。

6. }

// translation from arduino.cc

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值