Skip to content

Instantly share code, notes, and snippets.

@hsinghao
Last active May 16, 2017 06:21
模組介紹 : fayaLED模組_範例1
// 2017/5/15
// Faya-Nugget 範例程式 (RedLED8_1.ino)
// 單元: 模組介紹-fayaLED模組
// 網址: http://fayalab.blogspot.com/2017/05/faya-led.html
// 目標 (1) 設計LED跑馬燈,讓LED重複的由D0點依序亮到D7
// 接線: Arduino ==> faya模組
// 13 ==> D0 (LED模組)
// 12 ==> D1 (LED模組)
// 11 ==> D2 (LED模組)
// 10 ==> D3 (LED模組)
// 9 ==> D4 (LED模組)
// 8 ==> D5 (LED模組)
// 7 ==> D6 (LED模組)
// 6 ==> D7 (LED模組)
void setup() {
// 設定LED腳位為輸出
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
}
void loop() {
for(int i=13; i>=6; i-=1) // 從第13隻(D0)腳亮起,依序遞減
{
digitalWrite(i, HIGH); // 點亮
delay(500); // 等 0.5秒
digitalWrite(i, LOW); // 熄滅
delay(100); // 等 0.1秒
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment