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

Arduino Programming Basic - Bollean

RonWang1年前 (2024-04-29)电子编程330

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

Boolean-operators

Bollean运算

一般使用时B需要大写,C语言中bollean . 它是数学家 George Boole发明和命名的。&& 与运算 || 或运算 !非运算。 

if ((x>10) &&(x<50))

其它数据类型

boolean 占用内存(字节)1,范围: 0或1

char       占用内存(字节)1,范围: -128~+128

byte       占用内存(字节)1,范围: 0~255

int          占用内存(字节)2,范围: -32768~+32767

unsigned int   占用内存(字节)2,范围: 0~+65536

long       占用内存(字节)4,范围: -2147483648~+2147483647

unsigned long  占用内存(字节)4,范围: 0~+4294967295

float       占用内存(字节)4,范围:-3.4028235E+38~+-3.4028235E+38

double   占用内存(字节)4,和float 一样


1. 赋值语句 可以 int   a = 10;   也可以不带空格 int a=10; 都是正确的,关键是保持程序的写法一致,不要混用。

2. 注释语句  // 单行注释用,写在此行的结尾处

    多行注释  /*开头, 并用*/ 结尾 即可。


/* 本程序是LED闪烁功能。
   作者 Ron Wang
   编写与10月29日2022年 */
void loop()
{
   static int count = 0;
   count ++; // This line mean count= count + 1
   if (count == 20)
   {
   count = 0;
   delay(3000);  
   }
}

Code written on Arduino IDE Software

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

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

标签: Arduino

相关文章

Arduino Project 010 - Serial Controlled Mood Lamp

Arduino Project 010 - Serial Controlled Mood Lamp

For Project 10, you will revisit the circuit from Project 8 — RGB Mood Lamp, but you’ll now delve in...

 ​Arduino Project 048 - Human Body Infrared Detector and Relay Light

​Arduino Project 048 - Human Body Infrared Detector and Relay Light

Project 48 Human Body Infrared Detector and Relay Light/*  * Coding by Ronwang&...

Arduino Programming Basic - Variables

Arduino Programming Basic - Variables

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

Arduino Project 027 - Joystick Servo Control

Arduino Project 027 - Joystick Servo Control

In this tutorial, we are going to learn how to use Arduino and a joystick to control two servo motor...

Arduino Programming Basic - Funcation

Arduino Programming Basic - Funcation

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

Arduino Project 008 - RGB LED Mood Lamp

Arduino Project 008 - RGB LED Mood Lamp

In the last project, you learned how to adjust the brightness of an LED using the PWM capabilities o...