SlideShare a Scribd company logo
1 of 39
Download to read offline
Arduino S4A Sensor 
Board基礎實驗 
吳錫修 
sswu@nkut.edu.tw 
October 17, 2014 
Dept. of Electronics Engineering
shape the future 
Arduino IDE 1/4 
 下載Arduino整合開發環境軟體壓縮檔 
http://arduino.cc/en/Main/Software 
2 南開科大電子工程系 
 解壓至硬碟 
 USB連接PC與Arduino開發板
shape the future 
Arduino IDE 2/4 
3 南開科大電子工程系 
 安裝USB驅動程式
shape the future 
Arduino IDE 3/4 
 啟動Arduino IDE,確認Arduino開發板連接埠 
4 南開科大電子工程系
shape the future 
Arduino IDE 4/4 
5 南開科大電子工程系 
 切換中文介面 
 File/Preferences 
 重新開啟Arduino IDE
shape the future 
外掛ArduBlock 1/6 
 ArduBlock外掛軟體必須依附於Arduino IDE下運行 
 Arduino是文本式程式設計環境,而ArduBlock是以圖形 
化積木組合方式設計程式 
 可在ArduBlock設計圖控程式,再上傳至Arduino IDE 
 使程式設計視覺化,即使沒有Arduino程式語言基礎的 
人也可以嘗試編寫Arduino控制程式 
6 南開科大電子工程系
shape the future 
外掛ArduBlock 2/6 
7 南開科大電子工程系 
 下載ArduBlock 
 http://blog.ardublock.com/
shape the future 
外掛ArduBlock 3/6 
 將下載的ardublock-xxx.jar檔複製到Arduino IDE資料夾 
之tools/ArduBlockTool/tool子目錄即可(必要時自行 
建立子目錄) 
8 南開科大電子工程系
shape the future 
外掛ArduBlock 4/6 
 由Arduino IDE之Tools功能表,執行ArduBlock 
9 南開科大電子工程系
shape the future 
外掛ArduBlock 5/6 
10 南開科大電子工程系
shape the future 
外掛ArduBlock 6/6 
 Arduino IDE之語言設定必須選擇System Default, 
ArduBlock才會切換為中文介面 
11 南開科大電子工程系
shape the future 
S4A Sensor Board 1/3 
 四個RJ11接頭,可外接其他裝置(D2/D3, A3, A4, A5) 
 ⼀個⼀公分⼤⼩的按鍵開關(D2) 
12 南開科大電子工程系 
 ⼀個蜂鳴器(D9) 
 ⼀個麥克風( A2) 
 兩顆LED 顯示,⼀顆為紅⾊(D10),⼀顆為綠⾊(D11) 
 ⼀個滑桿可變電阻(10K),有效行程65mm (A0) 
 ⼀個光感測元件(A1) 
 預留⼀個藍芽孔位(UART)
shape the future 
S4A Sensor Board 2/3 
A4A3 A5 A4 A5 D2 D3 
13 南開科大電子工程系 
紅色LED D10 
綠色LED D11 
蜂鳴器D9 
光敏電阻A1 開關D2 
可變電阻A0 
N/A 
TX 
RX 
GND 
3.3V 
N/A 
D12 D4 D8 D7 D6 D5 
麥克風A2 
外接電源
shape the future 
S4A Sensor Board 3/3 
14 南開科大電子工程系
shape the future 
類比/數位訊號處理1/3 
 類比訊號:連續變化的物理訊號,訊號的振幅、頻率或 
相位可能隨時間變化 
 數位訊號:只由高/低二種電位訊號所組成 
15 南開科大電子工程系
shape the future 
類比/數位訊號處理2/3 
 Microcontrollers are digital devices – ON or OFF 
 類比訊號必須經由A/D轉換處理 
16 南開科大電子工程系
shape the future 
類比/數位訊號處理3/3 
 微處理器使用PWM(Pulse Width Modulation,脈波寬 
度調變)技術來輸出類比訊號 
 D3, D5, D6, D9, D10, D11支援PWM輸出 
 PWM 被應用在許多地方,調光燈具、馬達調速等 
17 南開科大電子工程系
shape the future 
Arduino輸出控制 
Digital OUTPUT 
 HIGH or LOW 
 PIN# -- 0 to 13 
pinMode( 11, OUTPUT ); 
digitalWrite( 11, HIGH ); 
Analog OUTPUT 
 0 to 255 
 PIN# -- 3, 5, 6, 9, 10, 11 
pinMode( 10, OUTPUT ); 
analogWrite ( 10, 128 ); 
18 南開科大電子工程系
shape the future 
19 南開科大電子工程系 
Lab 1 
 實驗目的 
 熟用數位輸出控制 
 讓S4A Sensor board D11 LED每0.5秒閃爍 
 參考檔案:led_do.adp
shape the future 
led_do.adp 
20 南開科大電子工程系
shape the future 
21 南開科大電子工程系 
Lab 2 
 實驗目的 
 熟用類比輸出控制 
 讓S4A Sensor board D10 LED由最亮每0.1秒漸暗,之後循環 
 參考檔案:led_ao.adp
shape the future 
led_ao.adp 
22 南開科大電子工程系
shape the future 
Arduino輸入控制 
Digital INPUT 
 Range: ?? 
 PIN# -- 0 to 13 
pinMode( 2, INPUT ); 
if ( digitalRead ( 2 )) 
{ 
} 
Analog INPUT 
 Range: ?? 
 PIN# -- 0 to 5 
pinMode( 0, OUTPUT ); 
i = analogRead ( 0 ); 
23 南開科大電子工程系
shape the future 
24 南開科大電子工程系 
Lab 3 
 實驗目的 
 熟用數位輸入控制 
 按下S4A Sensor board D2開關時, D11 LED亮;放開D2開關時, 
D11 LED不亮 
 參考檔案:sw_led.adp
shape the future 
sw_led.adp 
25 南開科大電子工程系
shape the future 
26 南開科大電子工程系 
Lab 4 
 實驗目的 
 熟用類比輸入控制 
 使用S4A Sensor board A0可變電阻調整D10 LED亮度 
 S4A Sensor board A0可變電阻讀值介於0~1023 
 參考檔案:vr_led.adp
shape the future 
vr_led.adp 
27 南開科大電子工程系
shape the future 
光敏電阻 
 光線照射時,CDS內原本處於穩定狀態的電子受到激發 
成為自由電子。所以光線越強,產生的自由電子也就愈 
多,電阻值就會變⼩ 
 註:受光時,S4A Sensor board A0光敏電阻讀值⼤ 
28 南開科大電子工程系
shape the future 
29 南開科大電子工程系 
Lab 5 
 實驗目的 
 熟用S4A Sensor board A0光敏電阻輸入控制 
 類比輸入控制、數位輸出 
 利用S4A Sensor board A0光敏電阻當作輸入裝置,當外界亮度 
比設定值⼩時讓S4A Sensor board D11 LED亮,否則讓LED亮燈 
號熄滅 
 設定值⼤⼩須根據現場環境調整 
 參考檔案:cds_led.adp
shape the future 
cds_led.adp 
30 南開科大電子工程系
shape the future 
蜂鳴器 
31 南開科大電子工程系 
 簡單的聲音輸出裝置 
 透過振動頻率控制,可輸出簡單的音階 
音階Do Re Mi Fa So La Si 
低音261 294 329 349 392 440 493 
中音523 587 659 698 784 880 988 
高音1046 1175 1318 1397 1568 1760 1976
shape the future 
32 南開科大電子工程系 
Lab 6 
 實驗目的 
 熟用S4A Sensor board D9蜂鳴器輸出控制 
 數位輸入控制、數位輸出 
 按⼀下S4A Sensor board D2按鍵讓D9蜂鳴器發出下課鐘聲 
 參考檔案:buzzer_music.adp,buzzer_music.ino 
Mi Do Rei So (低8) 
So (低8) Rei Mi Do 
Mi Rei Do So (低8) 
So (低8) Rei Mi Do
shape the future 
buzzer_music.adp 
33 南開科大電子工程系
shape the future 
buzzer_music.ino 
34 南開科大電子工程系 
int sound_pin = 9; // 蜂鳴器 
void setup() 
{ 
pinMode( 11 , OUTPUT); 
} 
void loop() 
{ 
if (digitalRead( 2)) 
{ 
sound(659, 523, 587, 392); 
sound(392, 587, 659, 523); 
sound(659, 587, 523, 392); 
sound(392, 587, 659, 523); 
} 
} 
void sound (int n1, int n2, int n3, int n4) 
{ 
// play a note on pin 9 
tone(sound_pin, n1, 1000); 
delay(1000); 
tone(sound_pin, n2, 1000); 
delay(1000); 
tone(sound_pin, n3, 1000); 
delay(1000); 
tone(sound_pin, n4, 1000); 
delay(1000); 
noTone(sound_pin); 
delay(1000); 
}
shape the future 
麥克風 
35 南開科大電子工程系 
 將聲波轉換為電子訊號 
 動圈式麥克風(Dynamic Microphone) 
當聲波進入麥克風,振膜受到聲波的壓力而產生振動,與振膜連 
接在⼀起的線圈則開始在磁場中移動產生感應電流。 
 電容式麥克風(Condenser Microphone) 
當聲波進入麥克風,振動膜產生振動,因為基板是固定的,使得 
振動膜和基板之間的距離會隨著振動而改變電容值 
 聲音愈⼤讀值愈⼤
shape the future 
36 南開科大電子工程系 
Lab 7 
 實驗目的 
 熟用S4A Sensor board A2麥克風輸入控制 
 類比輸入控制、數位輸出 
 利用麥克風偵測拍手聲音,當聲音輸入值⼤於設定值時(狀態)讓 
燈號亮,再拍⼀次則熄滅 
 需要debounce機制
shape the future 
mic_led.adp 
37 南開科大電子工程系
shape the future 
Arduino Language Reference 
 http://arduino.cc/en/Reference/HomePage 
38 南開科大電子工程系
39

More Related Content

What's hot

HC 05藍芽模組連線
HC 05藍芽模組連線HC 05藍芽模組連線
HC 05藍芽模組連線Chen-Hung Hu
 
Chapter 2 XBee無線傳輸
Chapter 2 XBee無線傳輸Chapter 2 XBee無線傳輸
Chapter 2 XBee無線傳輸CAVEDU Education
 
Chapter 3 XBee無線遙控車
Chapter 3 XBee無線遙控車Chapter 3 XBee無線遙控車
Chapter 3 XBee無線遙控車CAVEDU Education
 
Getting started with amarino
Getting started with amarinoGetting started with amarino
Getting started with amarino馬 萬圳
 
Arduino 習作工坊 - Lesson 4 通訊之夜
Arduino 習作工坊 -  Lesson 4 通訊之夜Arduino 習作工坊 -  Lesson 4 通訊之夜
Arduino 習作工坊 - Lesson 4 通訊之夜CAVEDU Education
 
使用 Arduino 控制 ESP8266 的各種方式
使用 Arduino 控制 ESP8266 的各種方式使用 Arduino 控制 ESP8266 的各種方式
使用 Arduino 控制 ESP8266 的各種方式Kenson Chiang
 
Arduino Basic
Arduino BasicArduino Basic
Arduino Basicmmiwwcom
 
Arduino Yun 物聯網 Lesson 1
Arduino Yun 物聯網 Lesson 1Arduino Yun 物聯網 Lesson 1
Arduino Yun 物聯網 Lesson 1CAVEDU Education
 
2018/1/16永春高中觸控燈研習
2018/1/16永春高中觸控燈研習2018/1/16永春高中觸控燈研習
2018/1/16永春高中觸控燈研習趙 亨利
 
Arduino 習作工坊 - Lesson 3 電音之夜
Arduino 習作工坊 -  Lesson 3 電音之夜Arduino 習作工坊 -  Lesson 3 電音之夜
Arduino 習作工坊 - Lesson 3 電音之夜CAVEDU Education
 

What's hot (20)

Chapter 1 what is arduino
Chapter 1 what is arduinoChapter 1 what is arduino
Chapter 1 what is arduino
 
HC 05藍芽模組連線
HC 05藍芽模組連線HC 05藍芽模組連線
HC 05藍芽模組連線
 
Arduino相關型錄
Arduino相關型錄Arduino相關型錄
Arduino相關型錄
 
Arduino基礎IO控制
Arduino基礎IO控制Arduino基礎IO控制
Arduino基礎IO控制
 
Chapter 2 XBee無線傳輸
Chapter 2 XBee無線傳輸Chapter 2 XBee無線傳輸
Chapter 2 XBee無線傳輸
 
Chapter 3 XBee無線遙控車
Chapter 3 XBee無線遙控車Chapter 3 XBee無線遙控車
Chapter 3 XBee無線遙控車
 
Arduino AMA中級認證術科實作 all
Arduino AMA中級認證術科實作 allArduino AMA中級認證術科實作 all
Arduino AMA中級認證術科實作 all
 
Getting started with amarino
Getting started with amarinoGetting started with amarino
Getting started with amarino
 
Microbit 1 introduction
Microbit 1 introductionMicrobit 1 introduction
Microbit 1 introduction
 
AMA 中級術科實作II
AMA 中級術科實作IIAMA 中級術科實作II
AMA 中級術科實作II
 
Arduino 習作工坊 - Lesson 4 通訊之夜
Arduino 習作工坊 -  Lesson 4 通訊之夜Arduino 習作工坊 -  Lesson 4 通訊之夜
Arduino 習作工坊 - Lesson 4 通訊之夜
 
使用 Arduino 控制 ESP8266 的各種方式
使用 Arduino 控制 ESP8266 的各種方式使用 Arduino 控制 ESP8266 的各種方式
使用 Arduino 控制 ESP8266 的各種方式
 
Arduino程式開發工具
Arduino程式開發工具Arduino程式開發工具
Arduino程式開發工具
 
Arduino Basic
Arduino BasicArduino Basic
Arduino Basic
 
Arduino Yun 物聯網 Lesson 1
Arduino Yun 物聯網 Lesson 1Arduino Yun 物聯網 Lesson 1
Arduino Yun 物聯網 Lesson 1
 
2018/1/16永春高中觸控燈研習
2018/1/16永春高中觸控燈研習2018/1/16永春高中觸控燈研習
2018/1/16永春高中觸控燈研習
 
Arduino 習作工坊 - Lesson 3 電音之夜
Arduino 習作工坊 -  Lesson 3 電音之夜Arduino 習作工坊 -  Lesson 3 電音之夜
Arduino 習作工坊 - Lesson 3 電音之夜
 
AMA 認證簡介
AMA 認證簡介AMA 認證簡介
AMA 認證簡介
 
AMA 中級術科實作IV
AMA 中級術科實作IVAMA 中級術科實作IV
AMA 中級術科實作IV
 
Arduino感測應用
Arduino感測應用Arduino感測應用
Arduino感測應用
 

Viewers also liked

使用CocoonJS發佈Construct 2專案到Android手機
使用CocoonJS發佈Construct 2專案到Android手機使用CocoonJS發佈Construct 2專案到Android手機
使用CocoonJS發佈Construct 2專案到Android手機吳錫修 (ShyiShiou Wu)
 
使用XDK發佈Construct 2專案到Android手機
使用XDK發佈Construct 2專案到Android手機使用XDK發佈Construct 2專案到Android手機
使用XDK發佈Construct 2專案到Android手機吳錫修 (ShyiShiou Wu)
 
Arduino Yún使用sd card儲存監測資料
Arduino Yún使用sd card儲存監測資料Arduino Yún使用sd card儲存監測資料
Arduino Yún使用sd card儲存監測資料吳錫修 (ShyiShiou Wu)
 
20142015機器人競賽資訊
20142015機器人競賽資訊20142015機器人競賽資訊
20142015機器人競賽資訊信仁 邱
 
2014探奇NXT機器人 wro v1
2014探奇NXT機器人 wro v12014探奇NXT機器人 wro v1
2014探奇NXT機器人 wro v1信仁 邱
 
2015機器人競賽資訊
2015機器人競賽資訊2015機器人競賽資訊
2015機器人競賽資訊信仁 邱
 
2015 wro比賽資訊
2015 wro比賽資訊2015 wro比賽資訊
2015 wro比賽資訊信仁 邱
 
機器人齊步走 V4 m_bot_mblock
機器人齊步走 V4 m_bot_mblock機器人齊步走 V4 m_bot_mblock
機器人齊步走 V4 m_bot_mblock信仁 邱
 

Viewers also liked (20)

Construct2簡介
Construct2簡介Construct2簡介
Construct2簡介
 
使用console訊息操作Arduino Yún IO
使用console訊息操作Arduino Yún IO使用console訊息操作Arduino Yún IO
使用console訊息操作Arduino Yún IO
 
Arduino Yún使用linino process
Arduino Yún使用linino processArduino Yún使用linino process
Arduino Yún使用linino process
 
XNA遊戲程式框架
XNA遊戲程式框架 XNA遊戲程式框架
XNA遊戲程式框架
 
Construct 2事件表作業
Construct 2事件表作業Construct 2事件表作業
Construct 2事件表作業
 
使用CocoonJS發佈Construct 2專案到Android手機
使用CocoonJS發佈Construct 2專案到Android手機使用CocoonJS發佈Construct 2專案到Android手機
使用CocoonJS發佈Construct 2專案到Android手機
 
使用XDK發佈Construct 2專案到Android手機
使用XDK發佈Construct 2專案到Android手機使用XDK發佈Construct 2專案到Android手機
使用XDK發佈Construct 2專案到Android手機
 
Construct 2 Physics behavior
Construct 2 Physics behaviorConstruct 2 Physics behavior
Construct 2 Physics behavior
 
Arduino Yún console連線
Arduino Yún console連線Arduino Yún console連線
Arduino Yún console連線
 
Arduino Yún使用sd card儲存監測資料
Arduino Yún使用sd card儲存監測資料Arduino Yún使用sd card儲存監測資料
Arduino Yún使用sd card儲存監測資料
 
8direction behavior
8direction behavior8direction behavior
8direction behavior
 
Avgminmax223
Avgminmax223Avgminmax223
Avgminmax223
 
Construct 2的Particles物件
Construct 2的Particles物件Construct 2的Particles物件
Construct 2的Particles物件
 
20142015機器人競賽資訊
20142015機器人競賽資訊20142015機器人競賽資訊
20142015機器人競賽資訊
 
2014探奇NXT機器人 wro v1
2014探奇NXT機器人 wro v12014探奇NXT機器人 wro v1
2014探奇NXT機器人 wro v1
 
2015機器人競賽資訊
2015機器人競賽資訊2015機器人競賽資訊
2015機器人競賽資訊
 
AMA 中級術科實作III
AMA 中級術科實作IIIAMA 中級術科實作III
AMA 中級術科實作III
 
2015 wro比賽資訊
2015 wro比賽資訊2015 wro比賽資訊
2015 wro比賽資訊
 
AMA 中級術科實作 I
AMA 中級術科實作 IAMA 中級術科實作 I
AMA 中級術科實作 I
 
機器人齊步走 V4 m_bot_mblock
機器人齊步走 V4 m_bot_mblock機器人齊步走 V4 m_bot_mblock
機器人齊步走 V4 m_bot_mblock
 

Similar to S4 a sensor board

#1247 Sensor and Controller Student book Chinese version-Part 1
#1247 Sensor and Controller Student book Chinese version-Part 1#1247 Sensor and Controller Student book Chinese version-Part 1
#1247 Sensor and Controller Student book Chinese version-Part 1Sandy Lu
 
物聯網概論 - Arduino
物聯網概論 - Arduino物聯網概論 - Arduino
物聯網概論 - ArduinoXianDe Liao
 
高二手眼實作-Arduino教學-1-第二週.pdf
高二手眼實作-Arduino教學-1-第二週.pdf高二手眼實作-Arduino教學-1-第二週.pdf
高二手眼實作-Arduino教學-1-第二週.pdf阿Samn的物理課本
 
程式人雜誌 -- 2013 年 2 月號
程式人雜誌 -- 2013 年 2 月號程式人雜誌 -- 2013 年 2 月號
程式人雜誌 -- 2013 年 2 月號鍾誠 陳鍾誠
 
Processing / Android / Arduino
Processing / Android / ArduinoProcessing / Android / Arduino
Processing / Android / ArduinoCAVEDU Education
 
開放硬體認知學習指引
開放硬體認知學習指引開放硬體認知學習指引
開放硬體認知學習指引MAKERPRO.cc
 
Topc open-platform-public
Topc open-platform-publicTopc open-platform-public
Topc open-platform-publicKenson Chou
 
LinkIt ONE tutorial #1- Basics
LinkIt ONE tutorial #1- BasicsLinkIt ONE tutorial #1- Basics
LinkIt ONE tutorial #1- BasicsCAVEDU Education
 
Arduino在農業、氣象與工業上的應用
Arduino在農業、氣象與工業上的應用Arduino在農業、氣象與工業上的應用
Arduino在農業、氣象與工業上的應用Victor Sue
 
LinkIt 7697 開發平台簡介 (Traditional Chinese)
LinkIt 7697 開發平台簡介 (Traditional Chinese)LinkIt 7697 開發平台簡介 (Traditional Chinese)
LinkIt 7697 開發平台簡介 (Traditional Chinese)Bear Wang
 
S3 cev40getting startv2.1 cn
S3 cev40getting startv2.1 cnS3 cev40getting startv2.1 cn
S3 cev40getting startv2.1 cnVidur Garg
 
Arduino workshop in Macau
Arduino workshop in MacauArduino workshop in Macau
Arduino workshop in Macauchiehming chang
 
20161222(105)教育訓練簡報
20161222(105)教育訓練簡報20161222(105)教育訓練簡報
20161222(105)教育訓練簡報小翰 蔡
 
3D Printer 關鍵軟體控制技術之分析與探討 @ COSCUP 2014
3D Printer 關鍵軟體控制技術之分析與探討 @ COSCUP 20143D Printer 關鍵軟體控制技術之分析與探討 @ COSCUP 2014
3D Printer 關鍵軟體控制技術之分析與探討 @ COSCUP 2014roboard
 
20200726-SINICA-自造生態監測系統工作坊
20200726-SINICA-自造生態監測系統工作坊20200726-SINICA-自造生態監測系統工作坊
20200726-SINICA-自造生態監測系統工作坊Victor Sue
 

Similar to S4 a sensor board (20)

#1247 Sensor and Controller Student book Chinese version-Part 1
#1247 Sensor and Controller Student book Chinese version-Part 1#1247 Sensor and Controller Student book Chinese version-Part 1
#1247 Sensor and Controller Student book Chinese version-Part 1
 
物聯網概論 - Arduino
物聯網概論 - Arduino物聯網概論 - Arduino
物聯網概論 - Arduino
 
Arduino overview
Arduino overviewArduino overview
Arduino overview
 
高二手眼實作-Arduino教學-1-第二週.pdf
高二手眼實作-Arduino教學-1-第二週.pdf高二手眼實作-Arduino教學-1-第二週.pdf
高二手眼實作-Arduino教學-1-第二週.pdf
 
程式人雜誌 -- 2013 年 2 月號
程式人雜誌 -- 2013 年 2 月號程式人雜誌 -- 2013 年 2 月號
程式人雜誌 -- 2013 年 2 月號
 
Processing / Android / Arduino
Processing / Android / ArduinoProcessing / Android / Arduino
Processing / Android / Arduino
 
Arduino應用系統設計 - 導論
Arduino應用系統設計 - 導論Arduino應用系統設計 - 導論
Arduino應用系統設計 - 導論
 
開放硬體認知學習指引
開放硬體認知學習指引開放硬體認知學習指引
開放硬體認知學習指引
 
Topc open-platform-public
Topc open-platform-publicTopc open-platform-public
Topc open-platform-public
 
LinkIt ONE tutorial #1- Basics
LinkIt ONE tutorial #1- BasicsLinkIt ONE tutorial #1- Basics
LinkIt ONE tutorial #1- Basics
 
Arduino yún簡介
Arduino yún簡介Arduino yún簡介
Arduino yún簡介
 
Arduino在農業、氣象與工業上的應用
Arduino在農業、氣象與工業上的應用Arduino在農業、氣象與工業上的應用
Arduino在農業、氣象與工業上的應用
 
LinkIt 7697 開發平台簡介 (Traditional Chinese)
LinkIt 7697 開發平台簡介 (Traditional Chinese)LinkIt 7697 開發平台簡介 (Traditional Chinese)
LinkIt 7697 開發平台簡介 (Traditional Chinese)
 
S3 cev40getting startv2.1 cn
S3 cev40getting startv2.1 cnS3 cev40getting startv2.1 cn
S3 cev40getting startv2.1 cn
 
LinkIt 7697 IoT tutorial
LinkIt 7697 IoT tutorialLinkIt 7697 IoT tutorial
LinkIt 7697 IoT tutorial
 
Arduino workshop in Macau
Arduino workshop in MacauArduino workshop in Macau
Arduino workshop in Macau
 
02 86 duino_簡介
02 86 duino_簡介02 86 duino_簡介
02 86 duino_簡介
 
20161222(105)教育訓練簡報
20161222(105)教育訓練簡報20161222(105)教育訓練簡報
20161222(105)教育訓練簡報
 
3D Printer 關鍵軟體控制技術之分析與探討 @ COSCUP 2014
3D Printer 關鍵軟體控制技術之分析與探討 @ COSCUP 20143D Printer 關鍵軟體控制技術之分析與探討 @ COSCUP 2014
3D Printer 關鍵軟體控制技術之分析與探討 @ COSCUP 2014
 
20200726-SINICA-自造生態監測系統工作坊
20200726-SINICA-自造生態監測系統工作坊20200726-SINICA-自造生態監測系統工作坊
20200726-SINICA-自造生態監測系統工作坊
 

More from 吳錫修 (ShyiShiou Wu)

Unity遊戲程式設計 - 2D Platformer遊戲
Unity遊戲程式設計 - 2D Platformer遊戲Unity遊戲程式設計 - 2D Platformer遊戲
Unity遊戲程式設計 - 2D Platformer遊戲吳錫修 (ShyiShiou Wu)
 
Unity遊戲程式設計 - 2D移動與碰撞處理II
Unity遊戲程式設計 - 2D移動與碰撞處理IIUnity遊戲程式設計 - 2D移動與碰撞處理II
Unity遊戲程式設計 - 2D移動與碰撞處理II吳錫修 (ShyiShiou Wu)
 
Unity遊戲程式設計 - 2D運動與碰撞處理I
Unity遊戲程式設計 - 2D運動與碰撞處理IUnity遊戲程式設計 - 2D運動與碰撞處理I
Unity遊戲程式設計 - 2D運動與碰撞處理I吳錫修 (ShyiShiou Wu)
 
Unity遊戲設計- 2D動畫製作及應用
Unity遊戲設計-  2D動畫製作及應用Unity遊戲設計-  2D動畫製作及應用
Unity遊戲設計- 2D動畫製作及應用吳錫修 (ShyiShiou Wu)
 

More from 吳錫修 (ShyiShiou Wu) (20)

Vuforia AR影片程式設計
Vuforia AR影片程式設計Vuforia AR影片程式設計
Vuforia AR影片程式設計
 
micro:bit亮度感測應用
micro:bit亮度感測應用micro:bit亮度感測應用
micro:bit亮度感測應用
 
Vuforia AR 同時追踨多張辨識圖
Vuforia AR同時追踨多張辨識圖Vuforia AR同時追踨多張辨識圖
Vuforia AR 同時追踨多張辨識圖
 
micro:bit開關控制應用
micro:bit開關控制應用micro:bit開關控制應用
micro:bit開關控制應用
 
Vuforia AR 應用程式設計入門
Vuforia AR應用程式設計入門Vuforia AR應用程式設計入門
Vuforia AR 應用程式設計入門
 
Vuforia AR 應用程式準備作業
Vuforia AR應用程式準備作業Vuforia AR應用程式準備作業
Vuforia AR 應用程式準備作業
 
micro:bit LED顯示控制
micro:bit LED顯示控制micro:bit LED顯示控制
micro:bit LED顯示控制
 
IDE for micro:bit
IDE for micro:bitIDE for micro:bit
IDE for micro:bit
 
使用Makeblock App學習mBot程式設計
使用Makeblock App學習mBot程式設計使用Makeblock App學習mBot程式設計
使用Makeblock App學習mBot程式設計
 
使用M部落App學習mBot程式設計
使用M部落App學習mBot程式設計使用M部落App學習mBot程式設計
使用M部落App學習mBot程式設計
 
nodeMCU IOT教學03 - NodeMCU導論
nodeMCU IOT教學03 - NodeMCU導論nodeMCU IOT教學03 - NodeMCU導論
nodeMCU IOT教學03 - NodeMCU導論
 
nodeMCU IOT教學02 - Lua語言
nodeMCU IOT教學02 - Lua語言nodeMCU IOT教學02 - Lua語言
nodeMCU IOT教學02 - Lua語言
 
Unity遊戲程式設計 - 2D Platformer遊戲
Unity遊戲程式設計 - 2D Platformer遊戲Unity遊戲程式設計 - 2D Platformer遊戲
Unity遊戲程式設計 - 2D Platformer遊戲
 
Unity遊戲程式設計 - 2D移動與碰撞處理II
Unity遊戲程式設計 - 2D移動與碰撞處理IIUnity遊戲程式設計 - 2D移動與碰撞處理II
Unity遊戲程式設計 - 2D移動與碰撞處理II
 
Unity遊戲程式設計 - 2D運動與碰撞處理I
Unity遊戲程式設計 - 2D運動與碰撞處理IUnity遊戲程式設計 - 2D運動與碰撞處理I
Unity遊戲程式設計 - 2D運動與碰撞處理I
 
Python與Ardinio整合應用
Python與Ardinio整合應用Python與Ardinio整合應用
Python與Ardinio整合應用
 
mBlock積木式設計程式
mBlock積木式設計程式mBlock積木式設計程式
mBlock積木式設計程式
 
Arduino程式除錯
Arduino程式除錯Arduino程式除錯
Arduino程式除錯
 
Unity遊戲設計- 2D動畫製作及應用
Unity遊戲設計-  2D動畫製作及應用Unity遊戲設計-  2D動畫製作及應用
Unity遊戲設計- 2D動畫製作及應用
 
Unity遊戲設計- 應用Sprite物件
Unity遊戲設計- 應用Sprite物件Unity遊戲設計- 應用Sprite物件
Unity遊戲設計- 應用Sprite物件
 

S4 a sensor board

  • 1. Arduino S4A Sensor Board基礎實驗 吳錫修 sswu@nkut.edu.tw October 17, 2014 Dept. of Electronics Engineering
  • 2. shape the future Arduino IDE 1/4  下載Arduino整合開發環境軟體壓縮檔 http://arduino.cc/en/Main/Software 2 南開科大電子工程系  解壓至硬碟  USB連接PC與Arduino開發板
  • 3. shape the future Arduino IDE 2/4 3 南開科大電子工程系  安裝USB驅動程式
  • 4. shape the future Arduino IDE 3/4  啟動Arduino IDE,確認Arduino開發板連接埠 4 南開科大電子工程系
  • 5. shape the future Arduino IDE 4/4 5 南開科大電子工程系  切換中文介面  File/Preferences  重新開啟Arduino IDE
  • 6. shape the future 外掛ArduBlock 1/6  ArduBlock外掛軟體必須依附於Arduino IDE下運行  Arduino是文本式程式設計環境,而ArduBlock是以圖形 化積木組合方式設計程式  可在ArduBlock設計圖控程式,再上傳至Arduino IDE  使程式設計視覺化,即使沒有Arduino程式語言基礎的 人也可以嘗試編寫Arduino控制程式 6 南開科大電子工程系
  • 7. shape the future 外掛ArduBlock 2/6 7 南開科大電子工程系  下載ArduBlock  http://blog.ardublock.com/
  • 8. shape the future 外掛ArduBlock 3/6  將下載的ardublock-xxx.jar檔複製到Arduino IDE資料夾 之tools/ArduBlockTool/tool子目錄即可(必要時自行 建立子目錄) 8 南開科大電子工程系
  • 9. shape the future 外掛ArduBlock 4/6  由Arduino IDE之Tools功能表,執行ArduBlock 9 南開科大電子工程系
  • 10. shape the future 外掛ArduBlock 5/6 10 南開科大電子工程系
  • 11. shape the future 外掛ArduBlock 6/6  Arduino IDE之語言設定必須選擇System Default, ArduBlock才會切換為中文介面 11 南開科大電子工程系
  • 12. shape the future S4A Sensor Board 1/3  四個RJ11接頭,可外接其他裝置(D2/D3, A3, A4, A5)  ⼀個⼀公分⼤⼩的按鍵開關(D2) 12 南開科大電子工程系  ⼀個蜂鳴器(D9)  ⼀個麥克風( A2)  兩顆LED 顯示,⼀顆為紅⾊(D10),⼀顆為綠⾊(D11)  ⼀個滑桿可變電阻(10K),有效行程65mm (A0)  ⼀個光感測元件(A1)  預留⼀個藍芽孔位(UART)
  • 13. shape the future S4A Sensor Board 2/3 A4A3 A5 A4 A5 D2 D3 13 南開科大電子工程系 紅色LED D10 綠色LED D11 蜂鳴器D9 光敏電阻A1 開關D2 可變電阻A0 N/A TX RX GND 3.3V N/A D12 D4 D8 D7 D6 D5 麥克風A2 外接電源
  • 14. shape the future S4A Sensor Board 3/3 14 南開科大電子工程系
  • 15. shape the future 類比/數位訊號處理1/3  類比訊號:連續變化的物理訊號,訊號的振幅、頻率或 相位可能隨時間變化  數位訊號:只由高/低二種電位訊號所組成 15 南開科大電子工程系
  • 16. shape the future 類比/數位訊號處理2/3  Microcontrollers are digital devices – ON or OFF  類比訊號必須經由A/D轉換處理 16 南開科大電子工程系
  • 17. shape the future 類比/數位訊號處理3/3  微處理器使用PWM(Pulse Width Modulation,脈波寬 度調變)技術來輸出類比訊號  D3, D5, D6, D9, D10, D11支援PWM輸出  PWM 被應用在許多地方,調光燈具、馬達調速等 17 南開科大電子工程系
  • 18. shape the future Arduino輸出控制 Digital OUTPUT  HIGH or LOW  PIN# -- 0 to 13 pinMode( 11, OUTPUT ); digitalWrite( 11, HIGH ); Analog OUTPUT  0 to 255  PIN# -- 3, 5, 6, 9, 10, 11 pinMode( 10, OUTPUT ); analogWrite ( 10, 128 ); 18 南開科大電子工程系
  • 19. shape the future 19 南開科大電子工程系 Lab 1  實驗目的  熟用數位輸出控制  讓S4A Sensor board D11 LED每0.5秒閃爍  參考檔案:led_do.adp
  • 20. shape the future led_do.adp 20 南開科大電子工程系
  • 21. shape the future 21 南開科大電子工程系 Lab 2  實驗目的  熟用類比輸出控制  讓S4A Sensor board D10 LED由最亮每0.1秒漸暗,之後循環  參考檔案:led_ao.adp
  • 22. shape the future led_ao.adp 22 南開科大電子工程系
  • 23. shape the future Arduino輸入控制 Digital INPUT  Range: ??  PIN# -- 0 to 13 pinMode( 2, INPUT ); if ( digitalRead ( 2 )) { } Analog INPUT  Range: ??  PIN# -- 0 to 5 pinMode( 0, OUTPUT ); i = analogRead ( 0 ); 23 南開科大電子工程系
  • 24. shape the future 24 南開科大電子工程系 Lab 3  實驗目的  熟用數位輸入控制  按下S4A Sensor board D2開關時, D11 LED亮;放開D2開關時, D11 LED不亮  參考檔案:sw_led.adp
  • 25. shape the future sw_led.adp 25 南開科大電子工程系
  • 26. shape the future 26 南開科大電子工程系 Lab 4  實驗目的  熟用類比輸入控制  使用S4A Sensor board A0可變電阻調整D10 LED亮度  S4A Sensor board A0可變電阻讀值介於0~1023  參考檔案:vr_led.adp
  • 27. shape the future vr_led.adp 27 南開科大電子工程系
  • 28. shape the future 光敏電阻  光線照射時,CDS內原本處於穩定狀態的電子受到激發 成為自由電子。所以光線越強,產生的自由電子也就愈 多,電阻值就會變⼩  註:受光時,S4A Sensor board A0光敏電阻讀值⼤ 28 南開科大電子工程系
  • 29. shape the future 29 南開科大電子工程系 Lab 5  實驗目的  熟用S4A Sensor board A0光敏電阻輸入控制  類比輸入控制、數位輸出  利用S4A Sensor board A0光敏電阻當作輸入裝置,當外界亮度 比設定值⼩時讓S4A Sensor board D11 LED亮,否則讓LED亮燈 號熄滅  設定值⼤⼩須根據現場環境調整  參考檔案:cds_led.adp
  • 30. shape the future cds_led.adp 30 南開科大電子工程系
  • 31. shape the future 蜂鳴器 31 南開科大電子工程系  簡單的聲音輸出裝置  透過振動頻率控制,可輸出簡單的音階 音階Do Re Mi Fa So La Si 低音261 294 329 349 392 440 493 中音523 587 659 698 784 880 988 高音1046 1175 1318 1397 1568 1760 1976
  • 32. shape the future 32 南開科大電子工程系 Lab 6  實驗目的  熟用S4A Sensor board D9蜂鳴器輸出控制  數位輸入控制、數位輸出  按⼀下S4A Sensor board D2按鍵讓D9蜂鳴器發出下課鐘聲  參考檔案:buzzer_music.adp,buzzer_music.ino Mi Do Rei So (低8) So (低8) Rei Mi Do Mi Rei Do So (低8) So (低8) Rei Mi Do
  • 33. shape the future buzzer_music.adp 33 南開科大電子工程系
  • 34. shape the future buzzer_music.ino 34 南開科大電子工程系 int sound_pin = 9; // 蜂鳴器 void setup() { pinMode( 11 , OUTPUT); } void loop() { if (digitalRead( 2)) { sound(659, 523, 587, 392); sound(392, 587, 659, 523); sound(659, 587, 523, 392); sound(392, 587, 659, 523); } } void sound (int n1, int n2, int n3, int n4) { // play a note on pin 9 tone(sound_pin, n1, 1000); delay(1000); tone(sound_pin, n2, 1000); delay(1000); tone(sound_pin, n3, 1000); delay(1000); tone(sound_pin, n4, 1000); delay(1000); noTone(sound_pin); delay(1000); }
  • 35. shape the future 麥克風 35 南開科大電子工程系  將聲波轉換為電子訊號  動圈式麥克風(Dynamic Microphone) 當聲波進入麥克風,振膜受到聲波的壓力而產生振動,與振膜連 接在⼀起的線圈則開始在磁場中移動產生感應電流。  電容式麥克風(Condenser Microphone) 當聲波進入麥克風,振動膜產生振動,因為基板是固定的,使得 振動膜和基板之間的距離會隨著振動而改變電容值  聲音愈⼤讀值愈⼤
  • 36. shape the future 36 南開科大電子工程系 Lab 7  實驗目的  熟用S4A Sensor board A2麥克風輸入控制  類比輸入控制、數位輸出  利用麥克風偵測拍手聲音,當聲音輸入值⼤於設定值時(狀態)讓 燈號亮,再拍⼀次則熄滅  需要debounce機制
  • 37. shape the future mic_led.adp 37 南開科大電子工程系
  • 38. shape the future Arduino Language Reference  http://arduino.cc/en/Reference/HomePage 38 南開科大電子工程系
  • 39. 39