// LED is connected to GPIO 2
const int ledPin = 18;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
// increase the LED brightness
for(int dutyCycle = 0; dutyCycle < 255; dutyCycle++) {
// changing the LED brightness with PWM
analogWrite(ledPin, dutyCycle);
delay(3);
}
// decrease the LED brightness
for(int dutyCycle = 255; dutyCycle > 0; dutyCycle--) {
// changing the LED brightness with PWM
analogWrite(ledPin, dutyCycle);
delay(3);
}
digitalWrite(14, HIGH);
Serial.println("Lampu ON");
delay(1000);
digitalWrite(14, LOW);
Serial.println("Lampu OFF");
delay(1000);
delay(10); // this speeds up the simulation
}