×

Arduino 教程

Arduino 概述Arduino 板的说明Arduino 安装Arduino 程序结构Arduino 数据类型Arduino 变量和常量Arduino 运算符Arduino 控制语句Arduino 循环Arduino 函数Arduino 字符串Arduino 字符串对象Arduino 时间函数Arduino 数组

Arduino 函数库

Arduino I/O函数Arduino 高级I/O函数Arduino 字符函数Arduino 数学库Arduino 三角函数

Arduino 进阶

Arduino Due 和 ZeroArduino 脉冲宽度调制Arduino 随机数Arduino 中断Arduino 通信Arduino 内部集成电路Arduino 串行外设接口

Arduino 项目

Arduino 闪烁LEDArduino 渐变LEDArduino 读取模拟电压Arduino LED条形图Arduino 键盘注销Arduino 键盘消息Arduino 鼠标按钮控制Arduino 键盘串口

Arduino传感器

Arduino 湿度传感器Arduino 温度传感器Arduino 水位检测器/传感器Arduino PIR传感器Arduino 超声波传感器Arduino 连接开关

Arduino 电机控制

Arduino 直流电机Arduino 伺服电机Arduino 步进电机

Arduino 声音

Arduino 音调库Arduino 无线通信Arduino 网络通信

Arduino 布尔运算符


Arduino 运算符Arduino 运算符


假设变量A为10,变量B为20,则:

运算符名称
运算符简写
描述 例子
and(与) && 称为逻辑运算符与。如果两个操作数都是非零,那么条件为真 (A && B)为真
or(或) || 称为逻辑OR运算符。如果两个操作数中的任何一个非零,则条件变为真。 (A || B)为真
not(非) ! 称为逻辑运算符非。用于反转其操作数的逻辑状态。如果条件为真,则逻辑运算符非将为假 !(A && B)为假


例子

void loop () {
   int a = 9,b = 4
   bool c = false;
   if((a > b)&& (b < a))
      c = true;
   else
      c = false;

   if((a == b)|| (b < a))
      c = true;
   else
      c = false;

   if( !(a == b)&& (b < a))
      c = true;
   else
      c = false;
}

结果

c = true
c = true
c = true

Arduino 运算符Arduino 运算符


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)