|科學園 -> 實驗物理技術:2009/02-06 -> Examples: blink|
Examples > Digital I/O
In most programming languages, the first program you write prints "hello world" to the screen. Since an Arduino board doesn't have a screen, we blink an LED instead.
The boards are designed to make it easy to blink an LED using digital pin 13. Some (like the Diecimila and LilyPad) have the LED built-in to the board. On most others (like the Mini and BT), there is a 1 KB resistor on the pin, allowing you to connect an LED directly. (To connect an LED to another digital pin, you should use an external resistor.)
LEDs have polarity, which means they will only light up if you orient the legs properly. The long leg is typically positive, and should connect to pin 13. The short leg connects to GND; the bulb of the LED will also typically have a flat edge on this side. If the LED doesn't light up, trying reversing the legs (you won't hurt the LED if you plug it in backwards for a short period of time).
The example code is very simple, credits are to be found in the comments.
/* Blinking LED
0最後修改紀錄: 2009/03/18(Wed) 00:58:37
尚未登入. (登入)since 2011/06/20 18:23