標籤

2014年1月7日 星期二

01閃爍的Led

配線:
ArduBlock程式:


Arduino 原始程式(源自Sketch草稿):
/*  (/*:用在很多行的附註說明,以/*開始,以*/結束。)
  Blink(閃爍)
  Turns on an LED on for one second, then off for one second, repeatedly.
  (不間斷的將Led打開1秒,之後關閉1秒)
*/

// (//此符號是用在附註說明只有1行) 
//Pin 13 has an LED connected on most Arduino boards.
//(定義Arduino上的第13個針腳的名稱為 led)
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
//void setup只有在程式執行時執行一次,通常用在定義變數
void setup() {                
  // initialize the digital pin as an output.
 //將led這個變數,初始化定義為輸出的裝置
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
//loop這個程式會不斷的執行
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)開燈
  delay(1000);               // wait for a second 等待1秒
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW 關燈
  delay(1000);               // wait for a second 等待1秒
}