跳轉至內容

初學者的 Arduino 指南/專案/使 LED 閃爍

50% developed
來自 Wikibooks,面向開放世界的開放書籍

在本章中,你將學習如何在 Arduino 板上使 LED 閃爍。這是你可以進行的最簡單的專案之一。

// this runs only once on power up
void setup() {
  pinMode(13, OUTPUT);
}

// the loop function runs continuously until the device is powered down
void loop() {
  digitalWrite(13, HIGH);   // turn on LED
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn off LED
  delay(1000);              // wait for a second
}
華夏公益教科書