• Increase font size
  • Default font size
  • Decrease font size
  • default color
  • cyan color
  • red color

Arduino.TW樂園

Member Area
閃爍LED(入門)
站長Blog文章單元 - 入門教學(連接小電阻,光敏,五分鐘搞定的)
作者是 xlinx   
週六, 11 二月 2006 23:55

LED閃爍語法:(轉載原官方網站上的程式碼,網址如下:www.arduino.cc/en/Tutorial/BlinkingLED)

 

/* Blinking LED
* ————
*
* turns on and off a light emitting diode(LED) connected to a digital
* pin, in intervals of 2 seconds. Ideally we use pin 13 on the Arduino
* board because it has a resistor attached to it, needing only an LED

*
* Created 1 June 2005
* copyleft 2005 DojoDave <http://www.0j0.org>
* http://arduino.berlios.de
*
* based on an orginal by H. Barragan for the Wiring i/o board
*/

int ledPin = 13;             // 這裡設定所要閃爍的LED燈腳位

void setup()
{
pinMode(ledPin, OUTPUT);     // 這裡設定所要輸出的PIN腳模式,OUTPUT = 輸出4V電壓
}

void loop()
{
digitalWrite(ledPin, HIGH);  // 設定PIN13腳位為高電位 = 4V
delay(1000);                 // 設定延遲時間,1000 = 1秒
digitalWrite(ledPin, LOW);   // 設定PIN13腳位為低電位 = 0V
delay(1000);                 // 設定延遲時間
}

由以上的範例可以製作出讓PIN13的腳位輸出一個每隔1秒鐘就產生高電位的閃爍效果。


blog comments powered by Disqus
最近更新在 週一, 07 九月 2009 02:39
 

幫助我們推廣