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

Arduino Programming Basic - Bollean

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

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

标签: Arduino

相关文章

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 Project 028B - Basic Stepper Control (Unipolar)

Arduino Project 028B - Basic Stepper Control (Unipolar)

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

Arduino Project 020 -  LED Dot Matrix Display - Beat Heart

Arduino Project 020 - LED Dot Matrix Display - Beat Heart

You’re going to use the same circuit, but with a slight variation in the code to create a multi-fram...

Arduino Project 045 - RFID Servo and LED Control System

Arduino Project 045 - RFID Servo and LED Control System

Arduino Programming Basic -- RFID Servo and LED Control System Project 45 RFID Servo...

Arduino Project 023B - Liquid Crystal Displays -Blink and Cursor

Arduino Project 023B - Liquid Crystal Displays -Blink and Cursor

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

 ​Arduino Project 051 - How to Connect Remote Control

​Arduino Project 051 - How to Connect Remote Control

Project 51 How to Connect Remote Control 4 Channel to Arduino// constants won't c...