這裡拿了利基的板子(OZONE,使用ATmega32u4,相容於arduino的leonardo板),來做為示範
有關ozone的資料再參考利基的網頁說明。
UNO的微控器用的是ATmega328,
Leonardo用的是ATmega32u4
OZONE為中間紅色板子,旁邊為一般的I/O實驗板
不囉嗦,直接看入門範例
在編輯環境中選擇 File->Examples->01.Basics->Blink
內建範例程式碼如下
=================================================================
01 /*
02 Blink
03 Turns on an LED on for one second, then off for one second, repeatedly.
04
05 This example code is in the public domain.
06 */
07
08 // Pin 13 has an LED connected on most Arduino boards.
09 // give it a name:
10 int led = 13;
11
12 // the setup routine runs once when you press reset:
13 void setup() {
14 // initialize the digital pin as an output.
15 pinMode(led, OUTPUT);
16 }
17
18 // the loop routine runs over and over again forever:
19 void loop() {
20 digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
21 delay(1000); // wait for a second
22 digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
23 delay(1000); // wait for a second
24 }
====================================================================
這裡使用板子上內建的一顆LED燈做為測試示範,該燈接於P13腳,在沒有任何的外接
電路下,即可練習初步指令。
本例執行結果,板上LED燈以每秒亮滅閃爍顯示
沒有留言:
張貼留言