CODE | Funcation - Arduino Programming Basic

RonWang4 years ago (2022-07-18)电子编程 COD15

Arduino 程序基础,介绍Arduino程序的基本组成,第一部分编写了10个例子,关于变量及变量名称,串口监视器,if循环,for循环,while循环等。第二部分介绍了函数,全局变量,局部变量和静态变量,数据类型,Bollean运算,注释语句等。

Funcations 函数

Functions in C and arduino

Flash 函数 2-1

int ledPin=13;
int delayPeriod =200;

void setup()
{
pinMode(ledPin,OUTPUT);
}

void loop()
{ 
  flash(20, delayPeriod);
  delay(3000);
 }
 
 void flash(int numFlashes, int d)
 {
  for( int i=0; i<numFlashes; i++)
   { digitalWrite(ledPin,HIGH);
     delay(d);
     digitalWrite(ledPin,LOW);
     delay(d);
  }
  }

函数的返回值 Return 2-2

int centToFaren(int c)
{
int f= c*9/5+32;
return f;
}
//函数调用

int pleasantTemp =centToFaren(20);

Code written on Arduino IDE Software

Share with Friends:

Related Articles

How to Selection Soldering for your Maker

How to Selection Soldering for your Maker

如何选用合适的电络铁?初级电子制作与维修之工具选择电烙铁是我们电子制作和装配中,导线、延长线连接,电子元件的安装和拆卸的必备工具。尤其是在电器维修中也是最常用的工具。电烙铁的分类电络铁的分类方式很多,…

Coding | 锻炼孩子的逻辑思维

Coding | 锻炼孩子的逻辑思维

自然语言(人类的语言)和计算机语言之间有许多相似之处,学习计算机语言类似于学习一门外语语法。 计算机编程或者算法的难点和意义是,是编程思维和解决问题能力。程序设计早已不是程序员们独有的技术活了,很多国…

Electric Maker Beginner Tools Kit

Electric Maker Beginner Tools Kit

This assortment of tools has everything you need to get started tinkering with Sparkfun products and…

CODE | LED Blink - Arduino Project 001

CODE | LED Blink - Arduino Project 001

Arduino 电子编程--灯项目及控制,主要使用Arduino编程控制LED灯,实现基本控制Project 1 LED闪烁,基本的应用Project 3和4红绿灯项目Project 1 …

CODE | Input and Output- Arduino Programming Basic

CODE | Input and Output- Arduino Programming Basic

The pins on the Arduino can be configured as either inputs or outputs. This document explains the fu…

CODE | Ultrasonic Distance Alarm - Arduino Project 040

CODE | Ultrasonic Distance Alarm - Arduino Project 040

The sensor consists of two primary components: a transmitter and a receiver . The transmitter is res…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.