SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
micro:bit加速度感測應用
Revised on August 9, 2021
 速度與加速度
 三軸加速度計
 三軸加速度計控制指令
 實作練習
 電子骰子
 運動方向指示器
 傾斜移動控制
 平衡控制遊戲
 地震偵測器
 速度定義為位置相對於時間的變化率,也可以稱為瞬時速度,以強調
與平均速度的區別
 𝑣
⃑
∆
∆
 加速度(m/s2)是速度向量(m/s)對於時間的變化率,描述速度的方向
和大小變化的快慢
 𝑎
⃑
 ⼀段時間內平均的速度變化,稱為平均加速度
 在極短時間內平均的速度變化,稱為瞬時加速度
 𝑣 𝑣 𝑎𝑡 𝑣 :末速,𝑣 :初速,𝑎:加速度,𝑡:時間
速度與加速度 1/2
2
速度與加速度 2/2
https://youtu.be/byngcwjO51U
3
 原理:透過可移動物體在固定電極片移動產生電容值差值,換算物體
重心的位移和方向
 搖晃micro:bit時會聽到「喀啦~喀啦~」的碰撞聲,就是三軸加速度計
內部移動體的碰撞聲
micro:bit三軸加速度計 1/2
4
固定電極片
移動體
固定電極片
X
Z
Y
X
Y Z
 MMA8653FC
micro:bit三軸加速度計 2/2
5
 讀取三軸加速度計三維度中其中⼀個的加速度值,或是所有維度的合
⼒,單位為千分之⼀G⼒ (重⼒加速度G = 9.80665m/s2)
strength3D = Math.sqrt(accelX * accelX + accelY * accelY + accelZ * accelZ)
三軸加速度計控制指令 1/2
6
X (left & right)
Y (back & forth)
Z (up & down)
 動作偵測
 分析加速度計3個軸向數值變化來推斷使用者操作micro:bit之動作
 晃動
 下側偏低
 上側偏低
 正面朝上
 背面朝上
 左側偏低
 右側偏低
 自由掉落
 3G動⼒、6G動⼒、8G動⼒
三軸加速度計控制指令 2/2
7
 初始顯示?,搖晃micro:bit控制板後隨機顯示1~6點,3秒後回復顯
示?
 隨機指令
實作練習 - 電子骰子 1/5
8
實作練習 - 電子骰子 2/5
9
分別編輯骰子點數,置入選擇結構中
 Python程式
def on_gesture_shake():
global Roll
Roll = randint(1, 6)
if Roll == 1:
basic.show_leds("""
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
""")
elif Roll == 2:
basic.show_leds("""
. . . . .
. . . # .
. . . . .
. # . . .
. . . . .
""")
實作練習 - 電子骰子 3/5
10
elif Roll == 3:
basic.show_leds("""
. . . . #
. . . . .
. . # . .
. . . . .
# . . # .
""")
elif Roll == 4:
basic.show_leds("""
. . . . .
. # . # .
. . . . .
. # . # .
. . . . .
""")
elif Roll == 5:
basic.show_leds("""
. . . . .
. # . # .
. . # . .
. # . # .
. . . . .
""")
實作練習 - 電子骰子 4/5
11
else:
basic.show_leds("""
. # . # .
. . . . .
. # . # .
. . . . .
. # . # .
""")
basic.pause(3000)
basic.show_string("?")
input.on_gesture(Gesture.SHAKE, on_gesture_shake)
Roll = 0
basic.show_string("?")
def on_forever():
pass
basic.forever(on_forever)
實作練習 - 電子骰子 5/5
12
實作練習 - 運動方向指示器 1/5
 顯示micro:bit控制板運動方向
 使用方向箭頭指示micro:bit控制板左右及前後移動,上下移動以大小菱
形表示
13
實作練習 - 運動方向指示器 2/5
14
實作練習 - 運動方向指示器 3/5
15
 Python程式
forward_backward = 0
up_down = 0
left_right = 0
def check_Y():
if forward_backward >= 1200:
basic.show_arrow(ArrowNames.NORTH)
if forward_backward <= -1200:
basic.show_arrow(ArrowNames.SOUTH)
def check_Z():
if up_down >= 100:
basic.show_icon(IconNames.SMALL_DIAMOND)
if up_down <= -2000:
basic.show_icon(IconNames.DIAMOND)
def check_X():
if left_right >= 1200:
basic.show_arrow(ArrowNames.WEST)
if left_right <= -1200:
basic.show_arrow(ArrowNames.EAST)
實作練習 - 運動方向指示器 4/5
16
def on_forever():
global left_right, forward_backward, up_down
left_right = input.acceleration(Dimension.X)
forward_backward = input.acceleration(Dimension.Y)
up_down = input.acceleration(Dimension.Z)
check_X()
check_Y()
check_Z()
basic.forever(on_forever)
實作練習 - 運動方向指示器 5/5
17
 光點(ball)初始位於正中央
 傾斜micro:bit來控制光點往低處移動
實作練習 - 傾斜移動控制 1/2
18
實作練習 - 傾斜移動控制 2/2
19
 光點初始位於正中央
 傾斜micro:bit來控制光點在點矩陣內部移動,每移動⼀格得1分,光
點碰到邊緣則結束遊戲
實作練習 - 平衡控制遊戲 1/5
20
實作練習 - 平衡控制遊戲 2/5
21
實作練習 - 平衡控制遊戲 3/5
22
 Python程式
def moving():
if input.acceleration(Dimension.X) > 150:
ball.change(LedSpriteProperty.X, 1)
score += 1
if input.acceleration(Dimension.X) < -150:
ball.change(LedSpriteProperty.X, -1)
score += 1
if input.acceleration(Dimension.Y) > 150:
ball.change(LedSpriteProperty.Y, 1)
score += 1
if input.acceleration(Dimension.Y) < -150:
ball.change(LedSpriteProperty.Y, -1)
score += 1
def isTouchingEdge():
if ball.is_touching_edge():
game.set_score(score)
game.game_over()
實作練習 - 平衡控制遊戲 4/5
23
ball = game.create_sprite(2, 2)
score = 0
def on_forever():
moving()
isTouchingdge()
basic.pause(200)
basic.forever(on_forever)
實作練習 - 平衡控制遊戲 5/5
24
實作練習 - 地震偵測器 1/3
25
實作練習 - 地震偵測器 2/3
26
實作練習 - 地震偵測器 3/3
27

Contenu connexe

Tendances

視知覺簡報 (包含春琪及孟君部分)
視知覺簡報  (包含春琪及孟君部分)視知覺簡報  (包含春琪及孟君部分)
視知覺簡報 (包含春琪及孟君部分)
宜燁 吳
 

Tendances (20)

mBot教學(11) 聲音感測應用
mBot教學(11) 聲音感測應用mBot教學(11) 聲音感測應用
mBot教學(11) 聲音感測應用
 
micro:bit LED顯示控制
micro:bit LED顯示控制micro:bit LED顯示控制
micro:bit LED顯示控制
 
mbot2.0教學-局域網路傳輸應用.pdf
mbot2.0教學-局域網路傳輸應用.pdfmbot2.0教學-局域網路傳輸應用.pdf
mbot2.0教學-局域網路傳輸應用.pdf
 
mBot 教學7 聲光控制應用
mBot 教學7 聲光控制應用mBot 教學7 聲光控制應用
mBot 教學7 聲光控制應用
 
mBot教學(5) - 超音波感測應用
mBot教學(5) - 超音波感測應用mBot教學(5) - 超音波感測應用
mBot教學(5) - 超音波感測應用
 
mBot 教學6 光感測器與LED應用
mBot 教學6 光感測器與LED應用mBot 教學6 光感測器與LED應用
mBot 教學6 光感測器與LED應用
 
mbot2.0教學-光感測器與LED應用.pdf
mbot2.0教學-光感測器與LED應用.pdfmbot2.0教學-光感測器與LED應用.pdf
mbot2.0教學-光感測器與LED應用.pdf
 
mbot2.0教學-超音波感測應用.pdf
mbot2.0教學-超音波感測應用.pdfmbot2.0教學-超音波感測應用.pdf
mbot2.0教學-超音波感測應用.pdf
 
mBot 教學5 超音波感測應用
mBot 教學5 超音波感測應用mBot 教學5 超音波感測應用
mBot 教學5 超音波感測應用
 
mBot教學(1) - mBot初體驗
mBot教學(1) - mBot初體驗mBot教學(1) - mBot初體驗
mBot教學(1) - mBot初體驗
 
mbot2.0教學-陀螺儀與三軸加速計應用.pdf
mbot2.0教學-陀螺儀與三軸加速計應用.pdfmbot2.0教學-陀螺儀與三軸加速計應用.pdf
mbot2.0教學-陀螺儀與三軸加速計應用.pdf
 
Mbot教學(1b) mBot初體驗
Mbot教學(1b) mBot初體驗Mbot教學(1b) mBot初體驗
Mbot教學(1b) mBot初體驗
 
機器人齊步走 Ver6 m_bot_mblock
機器人齊步走 Ver6 m_bot_mblock機器人齊步走 Ver6 m_bot_mblock
機器人齊步走 Ver6 m_bot_mblock
 
mBot 教學1 組裝與測試
mBot 教學1 組裝與測試mBot 教學1 組裝與測試
mBot 教學1 組裝與測試
 
mBot教學(8) - 巡線控制應用
mBot教學(8) - 巡線控制應用mBot教學(8) - 巡線控制應用
mBot教學(8) - 巡線控制應用
 
mBlock積木式設計程式
mBlock積木式設計程式mBlock積木式設計程式
mBlock積木式設計程式
 
micro:bit開關控制應用
micro:bit開關控制應用micro:bit開關控制應用
micro:bit開關控制應用
 
機器人齊步走 V4 m_bot_mblock
機器人齊步走 V4 m_bot_mblock機器人齊步走 V4 m_bot_mblock
機器人齊步走 V4 m_bot_mblock
 
視知覺簡報 (包含春琪及孟君部分)
視知覺簡報  (包含春琪及孟君部分)視知覺簡報  (包含春琪及孟君部分)
視知覺簡報 (包含春琪及孟君部分)
 
これからの KYC と Identity on Blockchain の動向
これからの KYC と Identity on Blockchain の動向これからの KYC と Identity on Blockchain の動向
これからの KYC と Identity on Blockchain の動向
 

Similaire à micro:bit加速度感測應用

Affective Computing and Intelligent Interaction (ACII 2011)
Affective Computing and Intelligent Interaction (ACII 2011)Affective Computing and Intelligent Interaction (ACII 2011)
Affective Computing and Intelligent Interaction (ACII 2011)
Lê Anh
 
Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)
brian d foy
 
Post CtA analyse for the CCP
Post CtA analyse for the CCPPost CtA analyse for the CCP
Post CtA analyse for the CCP
Jeroen Van der Eb
 
Mbd 04 multi-body_simulation_of_earthmoving_equipment_l&t
Mbd 04 multi-body_simulation_of_earthmoving_equipment_l&tMbd 04 multi-body_simulation_of_earthmoving_equipment_l&t
Mbd 04 multi-body_simulation_of_earthmoving_equipment_l&t
Anand Kumar Chinni
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL Basic
Ron Liu
 
Worst-Case Scheduling of Software Tasks
Worst-Case Scheduling of Software TasksWorst-Case Scheduling of Software Tasks
Worst-Case Scheduling of Software Tasks
Lionel Briand
 

Similaire à micro:bit加速度感測應用 (20)

Affective Computing and Intelligent Interaction (ACII 2011)
Affective Computing and Intelligent Interaction (ACII 2011)Affective Computing and Intelligent Interaction (ACII 2011)
Affective Computing and Intelligent Interaction (ACII 2011)
 
Day 2 slides UNO summer 2010 robotics workshop
Day 2 slides UNO summer 2010 robotics workshopDay 2 slides UNO summer 2010 robotics workshop
Day 2 slides UNO summer 2010 robotics workshop
 
MajesTech-Proposal
MajesTech-ProposalMajesTech-Proposal
MajesTech-Proposal
 
re:mobidyc the overview
re:mobidyc the overviewre:mobidyc the overview
re:mobidyc the overview
 
Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)
 
Motorized pan tilt(Arduino based)
Motorized pan tilt(Arduino based)Motorized pan tilt(Arduino based)
Motorized pan tilt(Arduino based)
 
Campaña Jorge diapositivas_proyecto_cinematica_en_coordenadas_tangenciales_no...
Campaña Jorge diapositivas_proyecto_cinematica_en_coordenadas_tangenciales_no...Campaña Jorge diapositivas_proyecto_cinematica_en_coordenadas_tangenciales_no...
Campaña Jorge diapositivas_proyecto_cinematica_en_coordenadas_tangenciales_no...
 
Post CtA analyse for the CCP
Post CtA analyse for the CCPPost CtA analyse for the CCP
Post CtA analyse for the CCP
 
Wearable Accelerometer Optimal Positions for Human Motion Recognition(LifeTec...
Wearable Accelerometer Optimal Positions for Human Motion Recognition(LifeTec...Wearable Accelerometer Optimal Positions for Human Motion Recognition(LifeTec...
Wearable Accelerometer Optimal Positions for Human Motion Recognition(LifeTec...
 
Mbd 04 multi-body_simulation_of_earthmoving_equipment_l&t
Mbd 04 multi-body_simulation_of_earthmoving_equipment_l&tMbd 04 multi-body_simulation_of_earthmoving_equipment_l&t
Mbd 04 multi-body_simulation_of_earthmoving_equipment_l&t
 
Embedded Programming for Quadcopters
Embedded Programming for QuadcoptersEmbedded Programming for Quadcopters
Embedded Programming for Quadcopters
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL Basic
 
Benchmarking and PHPBench
Benchmarking and PHPBenchBenchmarking and PHPBench
Benchmarking and PHPBench
 
Smart Room Gesture Control
Smart Room Gesture ControlSmart Room Gesture Control
Smart Room Gesture Control
 
Development of a biomechanical analysis process for use within a sports club
Development of a biomechanical analysis process for use within a sports club  Development of a biomechanical analysis process for use within a sports club
Development of a biomechanical analysis process for use within a sports club
 
µV: An Articulation, Rotation, Scaling, and Translation Invariant (ARST) Mult...
µV: An Articulation, Rotation, Scaling, and Translation Invariant (ARST) Mult...µV: An Articulation, Rotation, Scaling, and Translation Invariant (ARST) Mult...
µV: An Articulation, Rotation, Scaling, and Translation Invariant (ARST) Mult...
 
Worst-Case Scheduling of Software Tasks
Worst-Case Scheduling of Software TasksWorst-Case Scheduling of Software Tasks
Worst-Case Scheduling of Software Tasks
 
DAHO.AM 2015 - Abusing phones to make the internet of things
DAHO.AM 2015 - Abusing phones to make the internet of thingsDAHO.AM 2015 - Abusing phones to make the internet of things
DAHO.AM 2015 - Abusing phones to make the internet of things
 
Human action recognition with kinect using a joint motion descriptor
Human action recognition with kinect using a joint motion descriptorHuman action recognition with kinect using a joint motion descriptor
Human action recognition with kinect using a joint motion descriptor
 
iOS Unit Testing
iOS Unit TestingiOS Unit Testing
iOS Unit Testing
 

Plus de 吳錫修 (ShyiShiou Wu)

Plus de 吳錫修 (ShyiShiou Wu) (20)

mbot2.0教學-聲光控制應用.pdf
mbot2.0教學-聲光控制應用.pdfmbot2.0教學-聲光控制應用.pdf
mbot2.0教學-聲光控制應用.pdf
 
mbot2.0教學-移動控制.pdf
mbot2.0教學-移動控制.pdfmbot2.0教學-移動控制.pdf
mbot2.0教學-移動控制.pdf
 
mbot2.0教學-組裝與測試.pdf
mbot2.0教學-組裝與測試.pdfmbot2.0教學-組裝與測試.pdf
mbot2.0教學-組裝與測試.pdf
 
Python元組,字典,集合
Python元組,字典,集合Python元組,字典,集合
Python元組,字典,集合
 
Python函式
Python函式Python函式
Python函式
 
Python串列資料應用
Python串列資料應用Python串列資料應用
Python串列資料應用
 
Python 迴圈作業
Python 迴圈作業Python 迴圈作業
Python 迴圈作業
 
Python分支作業
Python分支作業Python分支作業
Python分支作業
 
Python基本資料運算
Python基本資料運算Python基本資料運算
Python基本資料運算
 
建置Python開發環境
建置Python開發環境建置Python開發環境
建置Python開發環境
 
C語言檔案處理
C語言檔案處理C語言檔案處理
C語言檔案處理
 
C語言列舉與聯合
C語言列舉與聯合C語言列舉與聯合
C語言列舉與聯合
 
C語言結構與串列
C語言結構與串列 C語言結構與串列
C語言結構與串列
 
C語言應用前置處理
C語言應用前置處理C語言應用前置處理
C語言應用前置處理
 
C語言函式
C語言函式C語言函式
C語言函式
 
C語言陣列與字串
C語言陣列與字串C語言陣列與字串
C語言陣列與字串
 
C語言迴圈作業
C語言迴圈作業C語言迴圈作業
C語言迴圈作業
 
C語言分支流程
C語言分支流程C語言分支流程
C語言分支流程
 
C語言運算式和運算子
C語言運算式和運算子C語言運算式和運算子
C語言運算式和運算子
 
C語言基本資料型別與變數
C語言基本資料型別與變數C語言基本資料型別與變數
C語言基本資料型別與變數
 

Dernier

Dernier (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

micro:bit加速度感測應用