/* Easy Arduino Tutorial: #3-1 Analog Output In this sketch we control the brightness of an LED using analog write (PWM). For Arduino UNO and Arduino NANO this only works with pins 3, 5, 6, 9, 10 and 11. Created by: InterlinkKnight Last modification: 2023-12-28 */ /////////////////////////// ////////// Pins /////////// /////////////////////////// const int LEDPin = 8; // Pin for LED void setup() // Start of setup - Runs once when we reset or power the board { // Set pins as input or output: pinMode(LEDPin, OUTPUT); // Set pin as output } // End of setup void loop() // Start of loop - Runs over and over again indefinitely { // Analog write the LED: analogWrite(LEDPin, 255); // ( [Pin] , [Value_0-255] ) delay(1000); // Wait this amount of milliseconds. 1000 milliseconds is 1 second // Analog write the LED: analogWrite(LEDPin, 20); // ( [Pin] , [Value_0-255] ) delay(1000); // Wait this amount of milliseconds. 1000 milliseconds is 1 second // Analog write the LED: analogWrite(LEDPin, 0); // ( [Pin] , [Value_0-255] ) delay(1000); // Wait this amount of milliseconds. 1000 milliseconds is 1 second } // End of loop