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

Arduino Programming Basic - Funcation

RonWang9个月前 (04-15)电子编程230

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://www.donstudio.cn/?id=247

标签: Arduino

相关文章

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

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

上大学时学习《C语言程序设计》(第二版)作者谭浩强,大部分编程时间是在学校机房度过,每次点开桌面的TurboC图标,就开始在里面敲代码,然后保存程序Abc.C,下一步进行编译,如果编译成功的话,就可以...

Arduino Project 026 - Dual Servo Control

Arduino Project 026 - Dual Servo Control

This project you’ll create another simple project, but this time you’ll control two servos using com...

Arduino Project 029 - Control Stepper Motor ULN2004A

Arduino Project 029 - Control Stepper Motor ULN2004A

Stepper motors, due to their unique design, can be controlled to a high degree of accuracy without a...

Arduino Project 015 - Simple Motor Control

Arduino Project 015 - Simple Motor Control

First, you’re going to simply control the speed of a DC motor in one direction, using a power transi...

Arduino Project 023D - Liquid Crystal Displays - Custom Character

Arduino Project 023D - Liquid Crystal Displays - Custom Character

Before wiring the LCD screen to your Arduino board we suggest to solder a pin header strip to the 14...

Arduino Project 023A - Liquid Crystal Displays - Autoscroll

Arduino Project 023A - Liquid Crystal Displays - Autoscroll

Before wiring the LCD screen to your Arduino board we suggest to solder a pin header strip to the 14...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。