Fade/Pemalap lampu
Hardware Required
- Arduino or Genuino board
- LED
- 220 ohm resistor
- wires
- breadboard
int led = 9;
int brightness = 0;
int fadeAmount = 1;
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
analogWrite(led, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(30);
}
int brightness = 0;
int fadeAmount = 1;
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
analogWrite(led, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(30);
}
No comments:
Post a Comment