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

Arduino Programming Basic - Bollean

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

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 034 - TM1637 4Digital 7Segment Display Module

Arduino Project 034 - TM1637 4Digital 7Segment Display Module

A standard 4-digit 7-segment display is needed for clock, timer and counter projects, but it usually...

Arduino Project 022 - LED Dot Matrix Display - Pong Game

Arduino Project 022 - LED Dot Matrix Display - Pong Game

This project was hard going and a lot to take in. So, for Project 22 you are going to create a simpl...

Arduino Project 030A - Dual Motor Driver L298N

Arduino Project 030A - Dual Motor Driver L298N

L298N Dual Motor Driver Project Description  The L298N Motor Driver is a control...

Arduino Project 019 - LED Dot Matrix Display - Basic Animation

Arduino Project 019 - LED Dot Matrix Display - Basic Animation

So far you have dealt with individual 5mm LEDs. LEDs can also be obtained in a package known as a do...

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

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