使用Arduino Software (IDE)內建範例開始練習
Built-in Examples are sketches included in the Arduino Software (IDE), to open them click on the toolbar menu: File > Examples.
These simple programs demonstrate all basic Arduino commands. They span from a Sketch Bare Minimum to Digital and Analog IO, to the use of Sensors and Displays.
1. Basics
Analog Read Serial: Read a potentiometer, print its state out to the Arduino Serial Monitor.
直接執行後啟動序列埠監控視窗,轉動可變電阻,觀察序列埠監控視窗的資料變化。
【練習】你可以讓序列埠監控視窗顯示光敏電阻的亮度變化值。
Bare Minimum: The bare minimum of code needed to start an Arduino sketch.
這是空白的程式架構
Blink: Turn an LED on and off.
直接執行可以看見藍色LED閃爍。
【練習】你可以改變LED閃爍的頻率。
Digital Read Serial: Read a switch, print the state out to the Arduino Serial Monitor.
直接執行可以觀察到按鈕開關1(SW1)狀態。
【練習】你可以改變成為觀察按鈕開關2(SW2)的狀態。
Fade: Demonstrates the use of analog output to fade an LED.
直接執行可以看見三色LED的紅色亮度在變化。
【練習】你可以改變讓三色LED的另外顏色在變化。
Read Analog Voltage: Reads an analog input and prints the voltage to the Serial Monitor.
直接執行後啟動序列埠監控視窗,轉動可變電阻,觀察序列埠監控視窗的資料變化。
【練習】你可以讓序列埠監控視窗的資料更新速度更新成為每秒2次。
Blink Without Delay: Blink an LED without using the delay() function.
Button: Use a pushbutton to control an LED.
Debounce: Read a pushbutton, filtering noise.
Digital Input Pullup: Demonstrates the use of INPUT_PULLUP with pinMode().
State Change Detection: Count the number of button pushes.
Tone Keyboard: A three-key musical keyboard using force sensors and a piezo speaker.
Tone Melody: Play a melody with a Piezo speaker.
直接執行時電路喇叭毫無反應。
【練習】你可以改變程式讓喇叭發出聲音?
Tone Multiple: Play tones on multiple speakers sequentially using the tone() command.
Tone Pitch Follower: Play a pitch on a piezo speaker depending on an analog input.
Arduino Software (IDE)新增元件程式庫
Arduino筆記:安裝 Arduino IDE 程式庫(Library)
Arduino 匯入的程式庫預設位置在 【(我的)文件】--> 【Arduino】--> 【libraries】底下,如果要刪除就直接進去刪掉就好。