Tinkercad Circuits:LED閃爍 (LED Blink )

若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。

If you like this post, please click the ads on the blog or buy me a coffee. Thank you very much.

本文要使用線上的Arduino模擬環境來示範 LED 閃爍,並說明積木程式產生出來的Arduino C語言之間的對應關係。This tutorial will teach the reader to use Tinkcercad circuits designing a LED blinking project. And illustrate the relationships between the blocks and C code.

材料(Materials):
  1. Arduino UNO R3 x 1
  2. LED x 1
  3. 220 ohm Resistor x 1
  4. Small Breadboard x 1

電路(Circuit):
LED blinking without breadboard


LED blinking with breadboard

The LED anode is connected to Arduino UNO pin 13. The LED cathode is connected to Arduino UNO ground.

程式碼(The Code):

上圖左邊是積木程式,右邊是 Arduino C 語言。舉例來說,左邊的 set built-in LED to HIGH 積木所對應的C語言為 digitalWrite(13, HIGH),wait 1 secs 對應的是 delay(1000)。也就是左邊的四個積木所對應的C語言程式碼是在右邊的 void loop() { .... } 裡。
The left side of the image is blocks and the right side of the image is Arduino C. For example, "set built-in LED to HIGH" is mapped to "digitalWrite(13, HIGH);" in Arduino C. That is, the four blocks on the left side of the image are mapped to the four lines of Arduino C code in the loop() body.

我們可以做底下的實驗(The Experiments):
1. 不使用電阻,LED燈會怎麼樣?What happens to LED without a resistor?
2. 將LED的正極接到Arduino 的數位腳位 4 (或其他),此時程式要怎麼修改?Connect LED anode to other Arduino digital pin(except 13). How to modify the code to let LED blinking?

示範影片(Demo Video):




範例連結(Example Link):
With breadboard: https://www.tinkercad.com/things/59tG0VQlOaF

沒有留言: