Arduino IDE 內建範例 與 對應電路的完整教學
Arduino IDE 內建範例 與 對應電路的完整教學
資料來源: https://docs.arduino.cc/built-in-examples/
Basics
Analog Read Serial
Read a potentiometer, print its state out to the Arduino Serial Monitor.
Bare Minimum code needed
The bare minimum of code needed to start an Arduino sketch.
Blink
Turn an LED on and off every second.
Digital Read Serial
Read a switch, print the state out to the Arduino Serial Monitor.
Fading a LED
Demonstrates the use of analog output to fade an LED.
Read Analog Voltage
Reads an analog input and prints the voltage to the Serial Monitor.
Digital
Blink Without Delay
Blink an LED without using the delay() function.
How to Wire and Program a Button
Learn how to wire and program a pushbutton to control an LED.
Debounce on a Pushbutton
Read a pushbutton, filtering noise.
InputPullupSerial
Demonstrates the use of INPUT_PULLUP with pinMode()
State Change Detection (Edge Detection) for pushbuttons
Count the number of button pushes.
Simple keyboard using the tone() function
A three-key musical keyboard using force sensors and a piezo speaker.
Play a Melody using the tone() function
Play a melody with a Piezo speaker.
Tone on Multiple Speakers
Play tones on multiple speakers sequentially using the tone() command.
Pitch follower using the tone() function
Play a pitch on a piezo speaker depending on an analog input.
Analog
Analog In, Out Serial
Read an analog input pin, map the result, and then use that data to dim or brighten an LED.
Analog Input
Use a potentiometer to control the blinking of an LED.
Analog Write with 12 LEDs on an Arduino Mega
Fade 12 LEDs on and off, one by one, using an Arduino Mega board.
Calibrate Sensor Input
Define a maximum and minimum for expected analog sensor values.
Fading
Use an analog output (PWM pin) to fade an LED.
Smoothing Readings From an Analog Input
Smooth multiple readings of an analog input.
Communication
ASCII Table
Demonstrates advanced Arduino serial output functions.
Create a LED Dimmer
Move the mouse to change the brightness of an LED.
Create a Graph with Processing
Send data to the computer and graph it in Processing.
MIDI Note Player
Send MIDI note messages serially.
Use Multiple Serial Ports on the Arduino Mega
Use two of the serial ports available on the Arduino Mega.
Physical Pixel
Turn a LED on and off by sending data to your Arduino from Processing or Max/MSP.
Read ASCII String
Parse a comma-separated string of integers to fade an LED.
Serial Call and Response (handshaking)
Send multiple variables using a call-and-response (handshaking) method.
Serial Call and Response (handshaking) with ASCII-encoded output
Send multiple variables using a call-and-response (handshaking) method, and ASCII-encode the values before sending.
SerialEvent
Demonstrates the use of serialEvent() function.
SerialPassthrough
Demonstrates how to virtually connect Serial and Serial1.
Virtual Color Mixer
This example demonstrates how to send multiple values from the Arduino board to the computer.
Control Structures
How to Use Arrays
A variation on the For Loop example that demonstrates how to use an array.
For Loop Iteration (aka The Knight Rider)
Control multiple LEDs with a for loop and.
Switch (case) Statement, used with sensor input
How to choose between a discrete number of values.
Switch (case) Statement, used with serial input
A second switch-case example, showing how to take different actions based on the characters received in the serial port.
While Loop
How to use a while loop to calibrate a sensor while a button is being read.
If Statement (Conditional Statement)
Use an if statement to change the output conditions based on changing the input conditions.
Sensors
ADXL3xx Accelerometer
Read an ADXL3xx accelerometer.
Detect a Knock
This tutorial shows you how to use a Piezo element to detect vibration.
Memsic 2125 Accelerometer
Learn how to read data from the Memsic 2125 Two-axis accelerometer.
Ping Ultrasonic Range Finder
Detect objects with an ultrasonic range finder.
Display
LED Bar Graph
Learn how to make an LED bar graph – a series of LEDs in a line.
Control an 8×8 matrix of LEDs.
Row-column Scanning to control an 8×8 LED Matrix.
Strings
Character Analysis
Use the operators to recognise the type of character we are dealing with.
String Addition Operator
Add strings together in a variety of ways.
String Appending Operators
Use the += operator and the concat() method to append things to Strings.
String Case Change Functions
Change the case of a string.
String Character Functions
Get/set the value of a specific character in a string.
String Comparison Operators
Learn how to make alphabetic comparisons between Strings. They are useful for sorting and alphabetizing, among other things.
String Object Constructors
Initialize string objects.
String indexOf() and lastIndexOf() Method
Look for the first/last instance of a character in a string.
How to Use String length()
This example shows you how to use this command to reply to an input from the Serial Monitor.
String length() and trim() Commands
Get and trim the length of a string.
String replace Function
The replace() function allows you to replace all instances of a given character in a string with another character.
String startsWith and endsWith Functions
Check which characters/substrings a given string starts or ends with.
String substring Function
Look for “phrases” within a given string.
String to Int Function
Allows you to convert a String to an integer number.
USB
Button Mouse Control
Control cursor movement with 5 pushbuttons.
Joystick Mouse Control
Controls a computer cursor movement with a Joystick when a button is pressed.
Keyboard and Mouse Control
Demonstrates the Mouse and Keyboard commands in one program.
Keyboard Logout
Logs out the current user with key commands.
Keyboard Message
Sends a text string when a button is pressed.
Keyboard Reprogram
Opens a new window in the Arduino IDE and reprograms the Leonardo with a simple blink program.
Keyboard Serial
Reads a byte from the serial port, and sends back a keystroke.
Arduino ISP
Arduino as ISP and Arduino Bootloaders
Arduino ISP turns your Arduino into an in-circuit programmer to re-program AtMega chips.
From Arduino to a Microcontroller on a Breadboard
Migrating an Arduino board to a standalone microcontroller on a breadboard.
基本
模擬讀取串行
讀取電位計,將其狀態打印到 Arduino 串行監視器。
所需的最低代碼
啟動 Arduino 草圖所需的最少代碼。
眨
每秒打開和關閉一個 LED。
數字讀取串行
讀取開關,將狀態打印到 Arduino 串行監視器。
使 LED 變暗
演示如何使用模擬輸出使 LED 變暗。
讀取模擬電壓
讀取模擬輸入並將電壓打印到串行監視器。
數字的
無延遲閃爍
在不使用 delay() 函數的情況下使 LED 閃爍。
如何接線和編程按鈕
了解如何對按鈕進行接線和編程以控制 LED。
按鈕上的去抖動
讀取按鈕,過濾噪音。
輸入上拉串行
演示如何將 INPUT_PULLUP 與 pinMode() 結合使用
按鈕的狀態變化檢測(邊緣檢測)
計算按鈕按下的次數。
使用tone()函數的簡單鍵盤
使用力傳感器和壓電揚聲器的三鍵音樂鍵盤。
使用tone()函數播放旋律
用壓電揚聲器播放旋律。
多個揚聲器上的音調
使用tone() 命令在多個揚聲器上依次播放音調。
使用tone()函數的音高跟隨器
根據模擬輸入在壓電揚聲器上播放音高。
模擬
模擬輸入,輸出串行
讀取模擬輸入引腳,映射結果,然後使用該數據使 LED 變暗或變亮。
模擬輸入
使用電位器來控制 LED 的閃爍。
在 Arduino Mega 上使用 12 個 LED 進行模擬寫入
使用 Arduino Mega 板一個一個地打開和關閉 12 個 LED。
校準傳感器輸入
定義預期模擬傳感器值的最大值和最小值。
衰退
使用模擬輸出(PWM 引腳)使 LED 變暗。
模擬輸入的平滑讀數
平滑模擬輸入的多個讀數。
溝通
ASCII 表
演示高級 Arduino 串行輸出功能。
創建 LED 調光器
移動鼠標以更改 LED 的亮度。
使用處理創建圖形
將數據發送到計算機並在Processing 中繪製它。
MIDI 音符播放器
串行發送 MIDI 音符信息。
在 Arduino Mega 上使用多個串行端口
使用 Arduino Mega 上可用的兩個串行端口。
物理像素
通過從 Processing 或 Max/MSP 向您的 Arduino 發送數據來打開和關閉 LED。
讀取 ASCII 字符串
解析以逗號分隔的整數字符串以淡出 LED。
串行(串列/RS232/RS-232) 呼叫和響應(握手)
使用調用和響應(握手)方法發送多個變量。
帶有 ASCII 編碼輸出的串行呼叫和響應(握手)
使用調用和響應(握手)方法發送多個變量,並在發送前對這些值進行 ASCII 編碼。
串行事件
演示 serialEvent() 函數的使用。
串行直通
演示如何虛擬連接 Serial 和 Serial1。
虛擬混色器
此示例演示如何將多個值從 Arduino 板發送到計算機。
控制結構
如何使用數組
For 循環示例的變體,演示瞭如何使用數組。
For 循環迭代(又名騎士騎士)
使用 for 循環和控制多個 LED。
Switch (case) 語句,與傳感器輸入一起使用
如何在離散數量的值之間進行選擇。
Switch (case) 語句,與串行輸入一起使用
第二個 switch-case 示例,展示瞭如何根據串行端口中接收到的字符採取不同的操作。
While 循環
如何在讀取按鈕時使用 while 循環校準傳感器。
If 語句(條件語句)
使用 if 語句根據更改輸入條件來更改輸出條件。
傳感器
ADXL3xx 加速度計
讀取 ADXL3xx 加速度計。
檢測敲擊聲
本教程向您展示如何使用壓電元件檢測振動。
Memsic 2125 加速度計
了解如何從 Memsic 2125 兩軸加速度計讀取數據。
Ping 超聲波測距儀
使用超聲波測距儀檢測物體。
展示
LED條形圖
了解如何製作 LED 條形圖 – 一行中的一系列 LED。
控制一個 8×8 的 LED 矩陣。
行列掃描控制 8×8 LED 矩陣。
字符串
性格分析
使用運算符來識別我們正在處理的字符類型。
字符串加法運算符
以多種方式將字符串添加在一起。
字符串追加運算符
使用 += 運算符和 concat() 方法將內容附加到字符串。
字符串大小寫更改函數
更改字符串的大小寫。
字符串字符函數
獲取/設置字符串中特定字符的值。
字符串比較運算符
了解如何在字符串之間進行字母比較。它們對於排序和按字母順序排列等很有用。
字符串對象構造函數
初始化字符串對象。
String indexOf() 和 lastIndexOf() 方法
在字符串中查找字符的第一個/最後一個實例。
如何使用字符串長度()
這位前任
One thought on “Arduino IDE 內建範例 與 對應電路的完整教學”
Arduino 內建範例 簡體中文 介紹
https://www.ncnynl.com/category/arduino-build-in-examples/