King_Tzeng
    • 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
      • Invitee
    • 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
    • Engagement control
    • 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 Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control 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
Invitee
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
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
###### tags: `iT邦幫忙鐵人賽`、`2019` # [Day 7] Johnny-Five 之 LED Level 1練習-Hello LED World! **新手上路!初進IoT的世界就從最簡單的開始吧!(ง๑ •̀_•́)ง** <br /> **發光二極體(Light-emitting diode),就是我們俗稱的「 LED 」** 回溯歷史,從只有紅光、綠光兩個顏色時代, 直到藍色光LED被研發出來造就現在的LED顏色光譜! > 節錄wiki - 2014年憑藉「發明高亮度藍色發光二極體,帶來了節能明亮的白色光源」,天野浩與赤崎勇、中村修二共同獲得諾貝爾物理學獎 *題外話~* 以前我在讀高職、大學的時候,也都沒有藍色LED可以用... 後來自己跑去光華商場買,**藍色一顆就要10元!**超貴的!(●▼●;) PS:紅、綠色一顆只要2、3元... <br /> ### 如何看極性? LED有極性之分,教大家怎麼看極性,我做了幾張圖來解說~ - **從外觀來判斷** 依規範來說,LED的端子**長腳為正極 短腳為負極** > 可以觀察本魯宅的 LED 的外觀(「・ω・)「 > > ![](https://1.bp.blogspot.com/-QJfM4UoeBOI/XWd4J0-O4FI/AAAAAAAATxo/2kcuJqa4sKIJXQFZnoERoGuasONP8HxrgCLcBGAs/s400/led-1.jpg) > <br/> <br/> **那你們心中一定會有很大的疑問~** Q:如果不小心在路上(欸?)撿到一顆LED,但是他的腳已經被剪掉了... 那要怎麼辨別呢? (|||゚д゚) <br /> *沒關係!還有方法可以辨別!* **仔細看LED的外觀邊緣處不是正圓形的,有一邊會有一個平面的特徵,那就是負極了!** > LED 包裝外觀的切面處 - 從下往上看 ~~(屁屁的地方~~ > > ![](https://1.bp.blogspot.com/-ZajHzUF79y4/XWd4KDDesVI/AAAAAAAATxs/d3Uyfk0zdjw7d2TZKBsV7gGtRTdkG44DwCLcBGAs/s400/led-2.jpg) > <br /> > LED 包裝外觀的切面處 - 從上往下看 > > ![](https://1.bp.blogspot.com/-GjDqRwXKyDE/XWd4KK3gldI/AAAAAAAATxw/uFX-NUx84VQDxUjKGgeax2r5Y0sAJdwcwCLcBGAs/s400/led-3.jpg) > <br /> 以上兩種是由外觀來辨別LED的極性~ 當然有一些廠商可能不會照著規範製作LED, 就會產生誤會了.... **最好還是用電表來測試一下LED的好壞,在寫程式的時候也可以先排除硬體故障的因素。** <br /> - 用電表來量測 電子的世界很大,無法把所有測試儀器都解釋,但是**三用電表一定是最基本要準備的!** > 各式各樣的三用電表~ > ![](https://1.bp.blogspot.com/-wZ6quMP4ehI/XWd_wSnw6YI/AAAAAAAATyA/int2DsLVzFA3-AUG8ua1XSz9EuRBJ28eQCLcBGAs/s640/ScreenPic%2B2019-08-29%2B%25E4%25B8%258B%25E5%258D%25883.31.12.png) <br /> ### 如何量測呢? 量測的方法是,**先調到蜂鳴(開斷路)測試檔,紅棒接LED的正腳,黑棒接LED的負腳** 如果**會亮就代表成功了!** 不亮的話反過來接再試一次,**如果上述重複測試都沒有亮的話,可能要考慮看看是不是LED燒毀或是瑕疵損毀等,換一顆吧~** > 先調到「 蜂鳴(開斷路)測試檔 」 > > ![](https://1.bp.blogspot.com/-gSWcPb2EFsU/XWzi4fsD2QI/AAAAAAAATy0/dVPexP7IBsMcGSIhh7wFGq2-bQs0qREsQCLcBGAs/s400/IMG_3891.jpeg) > <br /> > **紅棒接LED的正腳,黑棒接LED的負腳** 如果會亮就代表成功! > > ![](https://1.bp.blogspot.com/-mMWK2aJ_0_g/XWzjtHIe6SI/AAAAAAAATy8/9OAtMPYxpUYBVy18y1Kcr6qtrVqOS1vQwCLcBGAs/s400/test-led.gif) > <br /> LED 零件就介紹到這邊啦~(ゝ∀・)b <br /> <br /> ## Johnny-Five LED API 接下來要說Johnny-Five提供了什麼LED API 給我們~ > Johnny Five LED-http://johnny-five.io/api/led/#api 一共有**13種方法**可以讓我們做使用 ~~因為很多功能都差不多就省略不說了~(好偷懶~~ 新手LV1. 本篇就講解簡單的以下這些功能 **on( )**、**off( )**、**toggle( )**、**stop( )**、**strobe( )/blink( )** <br /> --- - **on( )** 功能:打開 LED --- ![](https://1.bp.blogspot.com/-7ml0_Fr8vNk/XV42y5S1c9I/AAAAAAAATw8/EVInWmCH-u0RDjFXfBhwKrwtw1RERSzXACPcBGAYYCw/s640/repl-on.gif) <br /> <br /> --- - **off( )** 功能:關閉LED。 --- **但是特別注意如果你的LED 正在執行strobe() 或是blink() 的話,執行 off() 會沒有作用!得先執行stop()函式停止strobe() 或是blink() 才行。** ![](https://1.bp.blogspot.com/-B1gXAM-5l-o/XV43fLUr7lI/AAAAAAAATxI/SgROMN9USjk3JjszTIMpbIVww-Y7gmV7QCPcBGAYYCw/s640/repl-off.gif) <br /> <br /> --- - **toggle( )** 切換LED目前的狀態。如果LED目前為亮則滅、為滅則亮。 --- ![](https://1.bp.blogspot.com/-Kn3CxgECwso/XWzUo6ws8rI/AAAAAAAATyc/yd8hNeh-PrIbxtmrwFFB_LbRYuF2ewiiACLcBGAs/s640/led-on-toggle.gif) <br /> <br /> --- - **strobe( ) / blink( )** 讓LED 亮→滅 頻率的閃爍。 --- **可以利用stop()的方式讓閃爍停止,但注意 停止的是他的計數器,而不是讓LED回到滅(Off)狀態!** *PS:strobe 和 blink 看不出有什麼差別.... 連官網的注釋都說 blink 只是 strobe 的別名而已(。ŏŏ)* ![](https://1.bp.blogspot.com/-WFDyrWIHetk/XWzbDMkVw3I/AAAAAAAATyo/UkuUvM0Wy3YsE9nyRb3WjCKatVXrcCXIwCLcBGAs/s640/repl-blink.gif) <br /> <br /> --- - stop( ) 停止計數器。 --- **讓blink、pulse等有時間週期類的動作停止。 但注意 停止的是他的計數器,而不是讓LED回到滅(Off)狀態!如果要完全的關閉LED需要呼叫stop()和off()。** <br /> 像這樣: ```javascript= // 完全關閉LED led.stop().off(); ``` ~~圖和off()那一張動圖一樣,就不放了..... <(_ _)>~~ <br /> **這些是基本的LED用法! 下一篇我們要講到有變化的PWM讓LED有更多的狀態喔~(๑•̀ㅂ•́)و✧** <br /> <br /> **本文到這邊先下台一鞠躬了~ 有錯敬請留言改正,感謝您的閱讀啦<(_ _)>** ## 文後 這些圖錄的好累R......(〒︿〒) --- 同步連載於blogger-[King 學習前端之人生](https://kingweblife.blogspot.com/search/label/%23iT%E9%82%A6%E9%90%B5%E4%BA%BA%E8%B3%BD%E7%B3%BB%E5%88%97%E6%96%87) 著作權為 Ying-chi Tzeng所有,轉載請告知,感謝您^^

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