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

Arduino Programming Basic - Bollean

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

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.parentscn.com/?id=249

标签: Arduino

相关文章

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...

Books Exploring Arduino

Books Exploring Arduino

Exploring Arduino uses the popular Arduino microcontroller platform as an instrument to teach topics...

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 003 - LED Traffic Light

Arduino Project 003 - LED Traffic Light

You are now going to create a set of traffic lights that will change from green to red, via amber, a...

 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 001 - LED Blink

Arduino Project 001 - LED Blink

Arduino 电子编程--灯项目及控制,主要使用Arduino编程控制LED灯,实现基本控制Project 1 LED闪烁,基本的应用Project 3和4红绿灯项目项目1 Project...