void setup() {
pinMode(A0, INPUT);
pinMode(6, OUTPUT);
Serial.begin(9600);
}
void loop() {
int a = analogRead(A0); // Read analog value
int pwm = map(a, 0, 1023, 0, 255); // Map analog value to PWM range
analogWrite(6, pwm); // Write PWM value to pin 3
Serial.print("Value Analog = ");
Serial.println(a);
Serial.print("Value PWM = ");
Serial.println(pwm);
delay(250);
}