許評詔 HSU PING JHAO E94111059
    • Create new note
    • Create a note from template
      • 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
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me 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

      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.
      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
    • Save as template
    • 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 Create Help
Create Create new note Create a note from template
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
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me 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

    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.
    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
    # 創客主線任務:Arduino 12/25(三) 這邊提供code給大家參考 希望大家可以先自己練習看看,寫不出來再比對這邊的code ## Button ```cpp= int led = 12; // LED腳位 int button = 2; // 按鈕腳位 void setup() { pinMode(button, INPUT); // 設定輸入腳位 pinMode(led, OUTPUT); // 設定輸出腳位 } void loop() { int state = digitalRead(button); // 讀取按鈕狀態 digitalWrite(led, state); // 狀態為1時,設置高電壓,否則設置低電壓 } ``` ## LED ```cpp= int led = 13; //建立 LED 控制變量void setup() { //準備 PIN 引腳輸出文件 pinMode(led, OUTPUT); } void loop() { //設定為高電壓 digitalWrite(led, HIGH); //等待 1000 毫秒 delay(1000); //設定為低電壓 digitalWrite(led, LOW); //等待 1000 毫秒 delay(1000); } ``` ## HF-06 藍牙模組 進入AT模式(壓著HC-05的按鈕進入) 在序列附輸入AT,如果回傳OK就是進入AT了 - AT+NAME? 可以查名字 - AT+PSWD? 可以查配對碼 - AT+UART? 可以查鮑率 - AT+NAME=你要設的名稱 可以改名字 - AT+PSWD=配對碼 可以設定配對碼 - AT+UART=鮑率,停止位元,同位位元 可以設定鮑率 ```cpp= #include <SoftwareSerial.h> SoftwareSerial BT(10, 11); //(接收腳,傳送腳) char val; void setup(){ // put your setup code here, to run once: Serial.begin(38400); Serial.println("BT is ready"); BT.begin(38400); } void loop() { // put your main code here, to run repeatedly: if (Serial.available()){ val = Serial.read(); BT.print(val); } if (BT.available()){ val = BT.read(); Serial.print(val); } } ``` ## 專案 ```cpp= #include <SoftwareSerial.h> SoftwareSerial bluetooth(10, 11); // 定義藍芽模組的軟體串口 #define a3f 208 // 208 Hz #define b3f 233 // 233 Hz #define b3 247 // 247 Hz #define c4 261 // 261 Hz MIDDLE C #define c4s 277 // 277 Hz #define e4f 311 // 311 Hz #define f4 349 // 349 Hz #define a4f 415 // 415 Hz #define b4f 466 // 466 Hz #define b4 493 // 493 Hz #define c5 523 // 523 Hz #define c5s 554 // 554 Hz #define e5f 622 // 622 Hz #define f5 698 // 698 Hz #define f5s 740 // 740 Hz #define a5f 831 // 831 Hz #define rest -1 #define NOTE_C4 262 #define NOTE_D4 294 #define NOTE_E4 330 #define NOTE_F4 349 #define NOTE_G4 392 #define NOTE_A4 440 #define NOTE_B4 494 #define LED_C 2 #define LED_D 3 #define LED_E 4 #define LED_F 5 #define LED_G 6 #define LED_A 7 #define LED_B 8 int piezo = 9; // Connect your piezo buzzer to this pin or change it to match your circuit! int led = LED_BUILTIN; volatile int beatlength = 135; // determines tempo float beatseparationconstant = 0.3; int threshold; int song1_chorus_melody[] = { b4f, b4f, a4f, a4f, f5, f5, e5f, b4f, b4f, a4f, a4f, e5f, e5f, c5s, c5, b4f, c5s, c5s, c5s, c5s, c5s, e5f, c5, b4f, a4f, a4f, a4f, e5f, c5s, b4f, b4f, a4f, a4f, f5, f5, e5f, b4f, b4f, a4f, a4f, a5f, c5, c5s, c5, b4f, c5s, c5s, c5s, c5s, c5s, e5f, c5, b4f, a4f, rest, a4f, e5f, c5s, rest }; int song1_chorus_rhythmn[] = { 1, 1, 1, 1, 3, 3, 6, 1, 1, 1, 1, 3, 3, 3, 1, 2, 1, 1, 1, 1, 3, 3, 3, 1, 2, 2, 2, 4, 8, 1, 1, 1, 1, 3, 3, 6, 1, 1, 1, 1, 3, 3, 3, 1, 2, 1, 1, 1, 1, 3, 3, 3, 1, 2, 2, 2, 4, 8, 4 }; const char* lyrics_chorus[] = { "Never ", "", "gonna ", "", "give ", "you ", "up\ \ ", "Never ", "", "gonna ", "", "let ", "you ", "down", "", "\ \ ", "Never ", "", "gonna ", "", "run ", "around ", "", "", "", "and ", "desert ", "", "you\ \ ", "Never ", "", "gonna ", "", "make ", "you ", "cry\ \ ", "Never ", "", "gonna ", "", "say ", "goodbye ", "", "", "\ \ ", "Never ", "", "gonna ", "", "tell ", "a ", "lie ", "", "", "and ", "hurt ", "you\ \ " }; void setup() { Serial.begin(9600); bluetooth.begin(38400); pinMode(LED_C, OUTPUT); pinMode(LED_D, OUTPUT); pinMode(LED_E, OUTPUT); pinMode(LED_F, OUTPUT); pinMode(LED_G, OUTPUT); pinMode(LED_A, OUTPUT); pinMode(LED_B, OUTPUT); } void loop() { if (bluetooth.available()) { char note = bluetooth.read(); switch (note) { case 'c': tone(9,NOTE_C4, 500); digitalWrite(LED_C, HIGH); delay(500); digitalWrite(LED_C, LOW); break; case 'd': tone(9,NOTE_D4, 500); digitalWrite(LED_D, HIGH); delay(500); digitalWrite(LED_D, LOW); break; case 'e': tone(9,NOTE_E4, 500); digitalWrite(LED_E, HIGH); delay(500); digitalWrite(LED_E, LOW); break; case 'f': tone(9,NOTE_F4, 500); digitalWrite(LED_F, HIGH); delay(500); digitalWrite(LED_F, LOW); break; case 'g': tone(9,NOTE_G4, 500); digitalWrite(LED_G, HIGH); delay(500); digitalWrite(LED_G, LOW); break; case 'a': tone(9,NOTE_A4, 500); digitalWrite(LED_A, HIGH); delay(500); digitalWrite(LED_A, LOW); break; case 'b': tone(9,NOTE_B4, 500); digitalWrite(LED_B, HIGH); delay(500); digitalWrite(LED_B, LOW); break; case 'F': tone(9,NOTE_B4, 500); delay(500); tone(9,NOTE_G4, 500); delay(500); tone(9,NOTE_D4, 500); delay(500); tone(9,NOTE_G4, 500); delay(500); tone(9,NOTE_A4, 500); delay(500); tone(9,NOTE_D4*2, 1000); delay(1000); tone(9,NOTE_A4/2, 500); delay(500); tone(9,NOTE_B4/2, 500); delay(500); tone(9,NOTE_A4/2, 500); delay(500); rick(); // tone(9,NOTE_D4/2, 500); // delay(500); // tone(9,NOTE_G4/2, 1500); // delay(1500); break; default: break; } } } void rick() { int notelength; int a = 0, b = 0, c = 0; while(a < 1){ // chorus notelength = beatlength * song1_chorus_rhythmn[b]; if (song1_chorus_melody[b] > 0) { digitalWrite(led, HIGH); bluetooth.print(lyrics_chorus[c]); tone(piezo, song1_chorus_melody[b], notelength); delay(notelength); c++; } b++; if (b >= sizeof(song1_chorus_melody) / sizeof(int)) { Serial.println(""); a++; } } } ```

    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

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    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