const int LED = 4; // Pin connected to the gate of the MOSFET (PWM)
int potentiometer_pin = 34; // Analog pin for the potentiometer(25,26)
int pot_value=0;
int pot_value_scaled = 0; // Variable to store potentiometer value
void setup() {
Serial.begin(9600);
pinMode(LED, OUTPUT); // Set the MOSFET pin as an output
}
void loop() {
pot_value = analogRead(potentiometer_pin);// Read potentiometer value
pot_value_scaled = map(pot_value, 0, 4095, 0, 255);
analogWrite(LED, pot_value_scaled);
delay(15); // Wait for 15 milliseconds
Serial.println(pot_value_scaled);
}