int ledPin = 6; // LED connected to digital pin 9
int brightness = 0; // variable to store the brightness value
int fadeAmount = 5; // how much to change the brightness by
// Define the LED pin
#define LED_PIN 9
// Define the potentiometer pin
#define POT_PIN A0
// Define a variable to store the potentiometer value
int potValue = 0;
// Define a variable to store the mapped value
int ledValue = 0;
void setup() {
// Set the LED pin as output
pinMode(LED_PIN, INPUT);
}
void loop() {
// Read the value from the potentiometer
potValue = analogRead(POT_PIN);
// Map the value from 0 to 1023 to 0 to 255
ledValue = map(potValue, 0, 1023, 0, 255);
// Write the mapped value to the LED pin
analogWrite(LED_PIN, ledValue);
// Wait for 10 milliseconds
delay(10);
}