C6 — Analogue outputs


Level 3 — Make an LED “breathe”
Complete the challenge
int ledPin = 10; // define the pin for the LED
int brightness = 0; // create a variable for the brightness of the LED
int direction = 0; // create a variable to say whether the LED should get brighter or dimmer
void setup() {
pinMode(ledPin, OUTPUT); // set up the ledPin as an OUTPUT
}
void loop() {
delay(10);
}
We’ll make the number 1
mean “getting brighter”, and the number 0
mean “getting dimmer”.
Go back up to level 1 to see how to increase the brightness.
Go back up to level 1 to see how to decrease the brightness.
Go back up to level 1 to see how to set the brightness.