当前位置:首页 > 科学研究 > 电子编程 > 正文内容

Arduino Programming Basic - Funcation

RonWang1年前 (2024-04-15)电子编程420

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

版权声明:本文为原创文章,版权归donstudio所有,欢迎分享本文,转载请保留出处!

本文链接:http://parentscn.com/?id=247

标签: Arduino

相关文章

 Arduino Project 033 - 4 Digital 7 Segment Display

Arduino Project 033 - 4 Digital 7 Segment Display

Showing Heep and number 0-9 on a Common Anode 7-segment LED display. Displays the numbers 0-9 on the...

Arduino Project 004 - LED Interactive Traffic Lights

Arduino Project 004 - LED Interactive Traffic Lights

This time you are going to extend the previous project to include a set of pedestrian lights and a p...

Arduino Project 021 -  LED Dot Matrix Display - Scrolling Message

Arduino Project 021 - LED Dot Matrix Display - Scrolling Message

There are many different ways to drive LEDs. Using shift registers is one way and they have their a...

Arduino Project 024 -  LCD Temperature Display

Arduino Project 024 - LCD Temperature Display

This project is a simple demonstration of using an LCD to present useful information to the user—in...

C语言调试运行环境Pelles C的安装

C语言调试运行环境Pelles C的安装

C语言调试运行环境之TurboC一文介绍了在32位Windows系统下安装C语言运行环境之TubroC,但是由于TurobC只能在32位系统下运行,导致现在很多Windows10和Windows 11...

Arduino Project 028A - Basic Stepper Control (Bipolar)

Arduino Project 028A - Basic Stepper Control (Bipolar)

In this very simple project, you will connect up a stepper motor and then get the Arduino to control...