arduino 習作工坊 - lesson 1 燈光之夜
TRANSCRIPT
![Page 1: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/1.jpg)
Arduino 習作計畫
#1 燈光
![Page 2: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/2.jpg)
提供優質服務
Total Solution Provider
![Page 3: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/3.jpg)
![Page 6: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/6.jpg)
Arduino Introduction
• Massimo Banzi 和 David Cuartielles所設計
• 採用低價位微處理器,Atmel Atmega8/168/328 單晶片
• 開放式的軟硬體平台
![Page 7: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/7.jpg)
Arduino UNO
USB Port
外接電源(DC)
Digital(PWM )通訊
Power燈
Reset
類比輸入電壓 in/out
![Page 9: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/9.jpg)
Install the Arduino Driver
![Page 10: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/10.jpg)
Getting Started
• 指定Arduino Driver資料夾位置
![Page 11: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/11.jpg)
Getting Started
• 打開裝置管理員,將”連接埠”展開,確認USB Serial Port
![Page 12: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/12.jpg)
Getting Started• 將Arduino.exe打開,在tools下選擇正確的Board與Serial
Port
![Page 13: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/13.jpg)
LED Blink
• File >> Examples >> 1.Basics >> Blink
![Page 14: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/14.jpg)
LED Blink
• Verify & Upload
Verify
Upload
Status
![Page 15: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/15.jpg)
How does it work?
void setup() { 初始化
}
void loop() { 重複執行
...}
![Page 16: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/16.jpg)
How does it work?
int led = 13;
void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT); }
void loop() {digitalWrite(led, HIGH); // set the LED on delay(1000);
// wait for a second digitalWrite(led, LOW); // set the LED off delay(1000); // wait for a second}
![Page 17: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/17.jpg)
動手寫寫看!
![Page 18: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/18.jpg)
基本範例(File >> Example >> Basic >> Fade)
![Page 19: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/19.jpg)
程式
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the
LED by
void setup() { // declare pin 9 to be an output:
pinMode(9, OUTPUT);
}
void loop() { // set the brightness of pin 9:
analogWrite(9, brightness); // change the
brightness for next time through the loop:
brightness = brightness + fadeAmount; // reverse
the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255){
fadeAmount = -fadeAmount ;
} // wait for 30 milliseconds to see the dimming
effect
delay(30);
}
![Page 20: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/20.jpg)
可變電阻
![Page 21: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/21.jpg)
讀取類比腳位狀態(File >> Example >> Basic>> AnalogReadSerial)
void setup() {Serial.begin(9600);
}
void loop() {int sensorValue = analogRead(A
0);Serial.println(sensorValue);
delay(1);
}
![Page 22: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/22.jpg)
接線
• 中間:A0~A5
• 一側:5V
• 另一側:GND
![Page 23: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/23.jpg)
可變電阻控制LED漸明漸暗(File >> Example >> Analog >> AnalogInOutSerial)
![Page 24: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/24.jpg)
光敏電阻
• 一端接A0,一端接地
• 由於是被動元件,需要在A0 那端加上5V
![Page 25: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/25.jpg)
電路示意圖
![Page 27: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/27.jpg)
![Page 28: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/28.jpg)
Fritzing
元件內容
元件庫繪圖區
![Page 29: Arduino 習作工坊 - Lesson 1 燈光之夜](https://reader034.vdocuments.net/reader034/viewer/2022042505/55a510931a28ab432d8b4591/html5/thumbnails/29.jpg)
123D circuits
• 由AutoDesk公司推出的線上電路模擬軟體