[[PageOutline]] == 1.環境 == * OS - Ubuntu 9.10 Desktop (32bit) * gcc-avr - 1:4.3.3-1 [[BR]] == 2.安裝開發工具於 Ubuntu == * 安裝 {{{ $ sudo aptitude install binutils-avr avrdude gcc-avr }}} * 安裝 [http://www.arduino.cc/en/Main/Software Arduino IDE] {{{ $ wget http://arduino.googlecode.com/files/arduino-0017.tgz $ tar zxvf arduino-0017.tgz $ cd arduino-0017 $ ./arduino }}} [[BR]] == 3.Hello World == * 先透過 USB 連接到電腦,若是有抓到 Arduino 板子的話,可以看到 PWR 燈和 L 燈會亮起來,可透過 dmesg 指令去察看 {{{ #!sh [ 51.480017] usb 4-2: new full speed USB device using uhci_hcd and address 5 [ 51.671681] usb 4-2: configuration #1 chosen from 1 choice [ 51.703685] usbcore: registered new interface driver usbserial [ 51.703703] USB Serial support registered for generic [ 51.703739] usbcore: registered new interface driver usbserial_generic [ 51.703742] usbserial: USB Serial Driver core [ 51.722008] USB Serial support registered for FTDI USB Serial Device [ 51.722100] ftdi_sio 4-2:1.0: FTDI USB Serial Device converter detected [ 51.722128] usb 4-2: Detected FT232RL [ 51.722131] usb 4-2: Number of endpoints 2 [ 51.722133] usb 4-2: Endpoint 1 MaxPacketSize 64 [ 51.722136] usb 4-2: Endpoint 2 MaxPacketSize 64 [ 51.722138] usb 4-2: Setting MaxPacketSize 64 [ 51.723643] usb 4-2: FTDI USB Serial Device converter now attached to ttyUSB0 [ 51.723662] usbcore: registered new interface driver ftdi_sio [ 51.723664] ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver }}} * 開啟 Arduino IDE,設定連接埠 [[Image(port.png,width=300px)]] * !HelloWorld 範例程式 (選取範例檔,如下圖) [[Image(HelloWorld.png,width=300px)]] * 編譯,按下 Verify 按鈕,若出現 「done compiling」表示編譯完成 [[Image(Verify.png,width=300px)]] * 燒錄至 Arduino 版子 [[Image(Upload.png,width=300px)]] * 察看 Console,此時可以觀察板子上的 TX 燈號會亮起,表示正在傳送狀態 [[Image(Console.png,width=300px)]] [[BR]] == 4.控制燈號 == * 此範例程式讓 L 燈亮5秒之後熄滅1秒,一樣透過 Arduino IDE "complie" 後再 "upload",之後可看 Arduino 板子上的 L 燈變化 {{{ #define LED 13 void setup() { } void loop() { digitalWrite(LED, HIGH); delay(5000); digitalWrite(LED, LOW); delay(1000); } }}}