arduino analogwrite

// Include the necessary library for Arduino
#include <Arduino.h>

// Define the pin for the LED
const int ledPin = 9;

void setup() {
  // Set the LED pin as an output
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // Use analogWrite to control the brightness of the LED
  analogWrite(ledPin, 128); // Set the brightness to 50% (0-255 range)
  delay(1000); // Wait for 1 second

  analogWrite(ledPin, 255); // Set the brightness to maximum
  delay(1000); // Wait for 1 second

  analogWrite(ledPin, 0); // Turn off the LED
  delay(1000); // Wait for 1 second
}