Created
November 14, 2014 07:31
-
-
Save peter01gb/47b962af099a8044ca52 to your computer and use it in GitHub Desktop.
如何讓一顆紅色的LED燈泡間隔2秒亮起熄滅?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/***************************************************************************** | |
如何讓一顆紅色的LED燈泡間隔2秒亮起熄滅? | |
這支程式碼code可以通過 Arduino IDE 1.0.6驗證 編譯完成 上傳到 Arduino Nano ATmega328 主控板 | |
可正確讓一顆LED燈泡間隔2秒亮起熄滅示 | |
這個練習很容易 | |
適合入門者 | |
就讓大家從控制一顆led小燈泡開始吧 | |
Let's go. | |
*****************************************************************************/ | |
//前面這兩條斜線後面的文字是註解,不會被執行 | |
void setup() //初始設定 | |
{ | |
pinMode(12, OUTPUT); // 將led連接到Arduino Nano ATmega328 主控板的12號數位接口 | |
} | |
void loop() //以下的程式會循環不斷的被Arduino Nano執行 | |
{ | |
digitalWrite(12, HIGH); // 設定LED在高電位也就是通電 | |
delay(2000); // 延遲2秒=通電2秒也就LED是發亮2秒鐘(1000是指1000毫秒,2秒等於2000毫秒) | |
digitalWrite(12, LOW); // 設定LED在低電位也就是斷電 | |
delay(2000); //delay(2000)是指斷電2秒也就是LED熄滅2秒鐘(同理設定3000就是熄滅3秒的意思) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment