-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArduino note.cpp
More file actions
250 lines (156 loc) · 4.07 KB
/
Arduino note.cpp
File metadata and controls
250 lines (156 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/**********************************************************************************************
**********************************************************************************************/
// File -> 使用编程器上传 无需启动引导,可直接烧录应用程序
/*
arduino在编译、链接、下载之后,hex文件自动删除了,造成软件仿真(如用proteus仿真)及其他单片机板应用的不便。
Hex文件的提取:
1: 在arduino工具的File->preferences中找到preferences.txt文件。
2:用记事本打开preferences.txt,选择hex文件存放的路径,在最后行加入 build.path=d:\arduino\MyHexDir,
3:关闭arduino。
4:关闭preferences.txt ,关闭时对话框显示是否保存,选择保存。 Note:1:hex文件存放的路径可以由自己来定。
*/
/*
Bootloader local
...\arduino-1.6.5\hardware\arduino\avr\bootloaders\optiboot
*/
/*
Arduino内存优化
#include <avr/pgmspace.h>
const data_type my_array[] PROGMEM =
pgm_read_byte
for (uint8_t i=0; i<16; i++) {
buffer[i] = pgm_read_byte(&table7[i]);
}
*/
@2018/6/14
Arduino UNO A0~A5 对应数字 14~19
/**********************************************************************************************
Arduino language reference
https://www.arduino.cc/reference/en/#functions
1. Functions
2. Veriables
3. Structure
**********************************************************************************************/
// 1. Functions
// Digital I/O ============================================================
digitalRead()
digitalWrite()
pinMode()
/**
* Reads the value from a specified digital pin, either HIGH or LOW.
* @pin: the number of the digital pin you want to read
* @return: HIGH or LOW
*/
digitalRead(pin);
/**
* Write a HIGH or a LOW value to a digital pin.
* @pin: the pin number
* @value: HIGH or LOW
*/
digitalWrite(pin, value);
/**
* Configures the specified pin to behave either as an input or an output.
* @pin: the number of the pin whose mode you wish to set
* @mode: INPUT, OUTPUT, or INPUT_PULLUP.
*/
pinMode(pin, mode);
// Analog I/O ============================================================
analogRead()
analogReference()
analogWrite()
/**
* Reads the value from the specified analog pin.
* @pin: the number of the analog input pin to read from.
* @return: int(0 to 1023)
*/
analogRead(pin)
// On most Arduino boards (those with the ATmega168 or ATmega328P), this function works on pins 3, 5, 6, 9, 10, and 11.
/**
* Writes an analog value (PWM wave) to a pin.
* @pin: the pin to write to. Allowed data types: int.
* @value: the duty cycle: between 0 (always off) and 255 (always on). Allowed data types: int
*/
analogWrite()
// Zero, Due & MKR Family =================================================
analogReadResolution()
analogWriteResolution()
// Advanced I/O
tone()
noTone()
pulseIn()
pulseInLong()
shiftIn()
shiftOut()
// tone()
Generates a square wave of the specified frequency (and 50% duty cycle) on a pin.
A duration can be specified, otherwise the wave continues until a call to noTone().
The pin can be connected to a piezo buzzer or other speaker to play tones.
// Time
delay()
delayMicroseconds()
micros()
millis()
// Math
abs()
constrain()
map()
max()
min()
pow()
sq()
sqrt()
// Trigonometry
cos()
sin()
tan()
// Characters
isAlpha()
isAlphaNumeric()
isAscii()
isControl()
isDigit()
isGraph()
isHexadecimalDigit()
isLowerCase()
isPrintable()
isPunct()
isSpace()
isUpperCase()
isWhitespace()
// Random Numbers
random()
randomSeed()
Bits and Bytes
bit()
bitClear()
bitRead()
bitSet()
bitWrite()
highByte()
lowByte()
// External Interrupts
attachInterrupt()
detachInterrupt()
Interrupts
interrupts()
noInterrupts()
// Communication
serial
stream
// USB
Keyboard
Mouse
// Software Serial
available()
begin()
isListening()
overflow()
peek()
read()
print()
println()
/**
* Enables the selected software serial port to listen. Only one software serial port can listen at a time;
*/
listen()
write()