阡陌 发表于 2024-3-10 18:41:44

概述(目录)



Arduino 编程语言可以分为三个主要部分:量值(变量和常量)、函数以及程序结构。



## 量值

包括数据类型、常量、变量以及量值间的转换等内容。

数据类型、常量和变量是编程基础中的核心概念,它们之间有着紧密的联系。

1. **数据类型**:数据类型定义了数据在内存中的存储方式以及可以进行的操作。C 语言提供了多种数据类型,包括基本数据类型(如 int、char、float、double 等)、复合数据类型(如数组、结构体、联合体等)以及指针类型等。每种数据类型都有其特定的存储大小和取值范围。
2. **常量**:常量是程序中固定不变的值。在 C 语言中,常量可以是任何基本数据类型或复合数据类型的值。例如,整数常量(如 100)、字符常量(如 'A')、浮点常量(如 3.14)等都是常见的常量。常量在程序中用于表示不会改变的值,如数学中的 π、物理中的重力加速度等。
3. **变量**:变量是程序中可以改变的值的存储位置。每个变量都有一个名字(标识符),以便在程序中引用它。变量还具有特定的数据类型,决定了它可以存储的数据类型和大小。在声明变量时,我们需要指定其数据类型,以便编译器知道如何为变量分配内存和进行相应的操作。



### 数据类型

这里主要介绍的是常用的基本数据类型。

- (https://www.mculoop.com/thread-208-1-1.html)
- (https://www.mculoop.com/thread-217-1-1.html)
- (https://www.mculoop.com/thread-207-1-1.html)
- (https://www.mculoop.com/thread-211-1-1.html)
- (https://www.mculoop.com/thread-218-1-1.html)
- (https://www.mculoop.com/thread-213-1-1.html)
- (https://www.mculoop.com/thread-221-1-1.html)
- (https://www.mculoop.com/thread-212-1-1.html)
- (https://www.mculoop.com/thread-219-1-1.html)
- (https://www.mculoop.com/thread-205-1-1.html)
- (https://www.mculoop.com/thread-206-1-1.html)
- (https://www.mculoop.com/thread-210-1-1.html)
- (https://www.mculoop.com/thread-209-1-1.html)
- [数组](https://www.mculoop.com/thread-204-1-1.html)
- [字符串](https://www.mculoop.com/thread-215-1-1.html)
- (https://www.mculoop.com/thread-216-1-1.html)
- (https://www.mculoop.com/thread-220-1-1.html)
- (https://www.mculoop.com/thread-214-1-1.html)



### 常量

- (https://www.mculoop.com/thread-227-1-1.html)
- (https://www.mculoop.com/thread-223-1-1.html)
- (https://www.mculoop.com/thread-224-1-1.html)
- (https://www.mculoop.com/thread-226-1-1.html)
- [整型常量](https://www.mculoop.com/thread-225-1-1.html)
- [浮点型常量](https://www.mculoop.com/thread-222-1-1.html)



### 类型转换

- (https://www.mculoop.com/thread-231-1-1.html)
- (https://www.mculoop.com/thread-230-1-1.html)
- (https://www.mculoop.com/thread-235-1-1.html)
- (https://www.mculoop.com/thread-233-1-1.html)
- [(unsigned int)](https://www.mculoop.com/thread-228-1-1.html)
- (https://www.mculoop.com/thread-234-1-1.html)
- [(unsigned long)](https://www.mculoop.com/thread-229-1-1.html)
- (https://www.mculoop.com/thread-232-1-1.html)



### 变量作用域与限定符

- const
- scope
- static
- volatile



### 辅助工具

- PROGMEM
- sizeof()



## 函数

用于控制 Arduino 板和执行计算。



### 数字 I/O

- digitalRead()
- digitalWrite()
- pinMode()



### 模拟 I/O

- analogRead()
- analogReadResolution()
- analogReference()
- analogWrite()
- analogWriteResolution()



### 高级 I/O

- noTone()
- pulseIn()
- pulseInLong()
- shiftIn()
- shiftOut()
- tone()



### 时间

- delay()
- delayMicroseconds()
- micros()
- millis()



### 数学

- abs()
- constrain()
- map()
- max()
- min()
- pow()
- sq()
- sqrt()



### 三角函数

- cos()
- sin()
- tan()



### 字符

- isAlpha()
- isAlphaNumeric()
- isAscii()
- isControl()
- isDigit()
- isGraph()
- isHexadecimalDigit()
- isLowerCase()
- isPrintable()
- isPunct()
- isSpace()
- isUpperCase()
- isWhitespace()



### 随机数

- random()
- randomSeed()



### 位与字节

- bit()
- bitClear()
- bitRead()
- bitSet()
- bitWrite()
- highByte()
- lowByte()



### 外部中断

- attachInterrupt()
- detachInterrupt()
- digitalPinToInterrupt()



### 中断

- interrupts()
- noInterrupts()



### 通信

- Print
- Serial
- SPI
- Stream
- Wire



### USB

- Keyboard
- Mouse



## 程序结构

### 程序草图

sketch(草图)是对 Arduino 程序的一种称呼,类似于艺术家在创作时的初稿。setup 与 loop 两个函数是它的较为显著的程序架构特征。

- loop()
- setup()



### 控制结构

- break
- continue
- do...while
- else
- for
- goto
- if
- return
- switch...case
- while



### 扩展语法

- \#define (宏定义)
- \#include (文件包含)
- /* */ (块注释)
- // (单行注释)
- ; (分号)
- {} (大括号)



### 算术运算符

- % (取模)
- \* (乘)
- \+ (加)
- \- (减)
- / (除)
- = (赋值)



### 比较运算符

- != (不等于)
- < (小于)
- <= (小于等于)
- == (等于)
- \> (大于)
- \>= (大于等于)



### 布尔运算符

- ! (逻辑非)
- && (逻辑与)
- || (逻辑或)



### 指针运算符

- & (取址)
- \* (指针)



### 位运算符

- & (按位与)
- << (左移)
- \>> (右移)
- ^ (按位异或)
- | (按位或)
- ~ (按位取反)



### 复合运算符

- %= (求余后赋值)
- &= (按位与后赋值)
- *= (乘后赋值)
- ++ (自增)
- += (加后赋值)
- -- (自减)
- -= (减后赋值)
- /= (除后赋值)
- ^= (按位异或后赋值)
- |= (按位或后赋值)



页: [1]
查看完整版本: 概述(目录)