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

Arduino Programming Basic - Bollean

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

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 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 043 - SD CardTemperature Datalogger

Arduino Project 043 - SD CardTemperature Datalogger

Todady I made a simple Arduino datalogger using SD card and DHT11  relative humidity and t...

Arduino Project 018 - Dual Shift Register 8-Bit Binary Counter

Arduino Project 018 - Dual Shift Register 8-Bit Binary Counter

In Project 18, you will daisy chain (or cascade) another 74HC595 IC onto the one used in Project 17...

 Arduino Project 037 - 18B20 Temperature Sensor

Arduino Project 037 - 18B20 Temperature Sensor

The DS18B20 Temperature Sensor is a digital temperature sensor capable of measuring temperatures wit...

Arduino Project 039 - Ultrasonic Distance Display

Arduino Project 039 - Ultrasonic Distance Display

Ultrasonic sensors measure distance by sending and receiving the ultrasonic wave. The ultrasonic sen...

Arduino Programming Basic - Input and Outpput

Arduino Programming Basic - Input and Outpput

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