Day 1 03 - for LED
2024. 1. 15. 19:13ㆍarduino
const int ledPin = 13;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(ledPin, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
for (int t = 0; t <= 10; t++) {
int cnt = 0;
while (true) {
digitalWrite(ledPin, HIGH);
delay(t);
digitalWrite(ledPin, LOW);
delay(10 - t);
cnt++;
if (cnt == 10) break;
}
}
}
for문을 이용해 점점밝아지는 LED
'arduino' 카테고리의 다른 글
Day1 06_LED8 (0) | 2024.01.17 |
---|---|
Day1 05_millis(라이브러리 호출) (0) | 2024.01.17 |
Day1 04_LED_mission (0) | 2024.01.17 |
Day 1 02 - serial (0) | 2024.01.15 |
Day 1 01 - LED (0) | 2024.01.15 |