const int potPin = A0; // Analog input pin for the potentiometer
const int mosfetPin = 9; // Digital output pin for the MOSFET gate
void setup() {
pinMode(mosfetPin, OUTPUT);
}
void loop() {
// Read the potentiometer value
int potValue = analogRead(potPin);
// Map the potentiometer value (0-1023) to PWM value (0-255)
int pwmValue = map(potValue, 0, 1023, 0, 255);
// Control the MOSFET using PWM
analogWrite(mosfetPin, pwmValue);
}