三民高中資訊教育課程
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- tags: HW(HomeWork) Guide --- # 0527/0602 課程 Code + HomeWork Guide - 注意: 有==黃標==的都是你要寫作業一定要看懂的地方。 - 注意2: 請不要把這裡當作你交作業的地方。交作業的地方在別的 page。 ## 電路圖 - 電路圖: ![](https://i.imgur.com/UBxg424.png =55%x) - 接線圖: ![](https://i.imgur.com/icSU34U.png =55%x) - 註: ==電容可以不用接沒關係==。在模擬器中不影響功能 ### 電路解析 - 此電路圖是一個控制 Servo 進行旋轉的電路。 - 在可變電阻旁邊,你可以看到本次作業多了兩個新的元件: - 電容 (Capacitor): - ![](https://i.imgur.com/uEjJTaP.png) - 是一個**儲存電壓能量的元件**,在沒有**外加電位差**的時候會將電容內的電壓放出。 - 在電路中起到**穩定電源**的作用。(就像臨時發電機 or 蓄水塔一樣) - ==拔不拔除不影響功能==,但是可以幫助電路濾除雜訊、防止 **真實 Servo 一時需要太多電流而導致功能失常**的問題。 - ==電位計== (Potentiometer): - ![](https://i.imgur.com/QhLsVgY.png) - ==可以當作是可變電阻的一種== - 會有一個可以旋轉的物理介面,會改變==圖中箭頭指到的電阻位置==,所以會改變分壓比例 - 實際上的等效電路如圖,只是==物理上會因為 arrow(箭頭) 的上移導致 R1 變小而 R2 變大==,反之==下移的時候 R2 變小 R1 變大== ![](https://i.imgur.com/tNKdPMA.png =45%x) - 而我們在過去的 Slide 中知道: ==R1、R2 的比例會因為分壓律的關係,使我們電阻上分到的電壓差不同==: ![](https://i.imgur.com/5oUHkwz.png) ## Code ```C= // // Arduino Starter Kit projects // // Created by Claudio Carnino // Modified by Josh Chang // Copyright © 2021 Futurenest. All rights reserved. //https://hackmd.io/CC-l35guRkaAayxbZu8UyQ# // 載入 Servo 函式庫的標頭檔 #include <Servo.h> enum PinId { PinIdPontentiometerOutput = A0, PinIdServoMotorInput = 9, }; enum PontentiometerOutputValue { PontentiometerOutputValueMin = 0, PontentiometerOutputValueMax = 1023, }; enum ServoMotorInputAngle { ServoMotorInputAngleMin = 0, ServoMotorInputAngleMax = 179, }; const int loopCycleDelayMilliseconds = 15; // 宣告一個 Servo 的物件實體 Servo servoMotor; int potentiometerValue; int servoMotorAngle; void setup() { // 告知伺服馬達所使用的腳位 servoMotor.attach(PinIdServoMotorInput); Serial.begin(9600); } void loop() { // 讀取電位器數值 potentiometerValue = analogRead(PinIdPontentiometerOutput); Serial.print("PontentiometerOutputPin: "); Serial.print(potentiometerValue); // 計算伺服馬達轉動角度:將電位器變化數值轉換為 0-180 度。 servoMotorAngle = map(potentiometerValue, PontentiometerOutputValueMin, PontentiometerOutputValueMax, ServoMotorInputAngleMin, ServoMotorInputAngleMax); Serial.print(", angle: "); Serial.println(servoMotorAngle); // 轉動伺服馬達 servoMotor.write(servoMotorAngle); delay(loopCycleDelayMilliseconds); } ``` ### Code 解析 - `enum` 不影響我們對本次 Code 的邏輯理解。 - `servoMotor.attach(<PIN_NAME>)` 是用來告訴 Arduino 對於 `PinIdServoMotorInput` 此一引腳要接上 Servo - 所以在本次 Code,意義上跟 `servoMotor.attach(9)` 等價,原因是因為在 Code 的第 14 行,我們設定了 `PinIdServoMotorInput = 9` 當作變數。 ```C= void setup() { // 告知伺服馬達所使用的腳位 servoMotor.attach(PinIdServoMotorInput); Serial.begin(9600); } ``` - `map(<input_Variable>, <input_fromLow>, <input_fromHigh>, <input_toLow>, <input_toHigh>)` 指的是將 `<input_Variable>` 對應的數字的==尺度放大== - 舉個例子,如果我現在有一把尺,刻度 0~10 裡面存在一個點,它在 `5` 上面,也就是==在這把尺的中間== - 則如果我換另一把只有 0~5 刻度的尺,那==如果我把這個點放在這把尺的中間==,則對應到的刻度只有 `2.5` 而已。 - map 就是在把這個 "點" 做==尺跟尺之間的尺度互換==,`fromLow/High` 就是你原本的尺,`toLow/High` 就是你想換過去的新尺。 - `servoMotor.write(<ANGLE>);` 指的是==要讓 servo 轉幾度==,以 `servoMotor.write(servoMotorAngle);` 來說,就是讓 Servo 轉 `servoMotorAngle = ????` 度 - `????` 是程式中 "你" 寫的東西,在 `map` 那邊被決定。 ## 作業內容 ### 問題一 - 請利用==之前在 Tinkercad用過的三用電表功能==,觀察下方三張圖,在這三張圖對應的 Servo 角度中,回答==類比輸入 A0 的 "對地" 電壓是多少==,並擷取圖片 - ![](https://i.imgur.com/vsJNeit.png) - ![](https://i.imgur.com/9rqmDU1.png) - ![](https://i.imgur.com/gsw8KrH.png) - 圖片一樣請按照過往作業格式,學號 + 姓名寫入註解並上傳,以下是回答範例: - ![](https://i.imgur.com/KZcN4iS.png) - 記得圖片中==要有電壓數值==。 ### 問題二 - 觀察問題 1 跟 Code,為何我調整電位計就可以改變 Servo 的位置?我在程式中作了什麼事情?請詳述程式流程==及該流程中每個函數的物理意義==。 ### 問題三 - 請觀察上述的電位計電路,並請在 Tinkercad 中使用麵包版接出一個==測量 "電位計中點的對地電位差" 功能的電路==,並截圖 + 加入學號姓名的註解。 - 這題你會用到: - Tinkercad 的電表![](https://i.imgur.com/J9xhBTy.png =25%x) - 電位計的 "中點" 就是中間那一根腳。![](https://i.imgur.com/xRDychQ.png =15%x) - 對地電位差: 請參考第二週 Slide 中==對於絕對電位的定義==。 ### 問題四 請回答以下小題: - 對於本次課程的負擔,如果 0~10 以滿分十分來當作受不了的標準, 請說一下你會打幾分? - 承上題,請問原因是? - 需要對哪一個知識做補述?

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully