#define analogInPin A0
#define pwmOutPin 2
uint16_t sensorValue,outputValue,percentValue;
void setup() {
pinMode(pwmOutPin,OUTPUT);
pinMode(analogInPin,INPUT);
}
void loop(){
// Read the PWM value of the input potentiometer.
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// map pump speed percent of full scale
percentValue = map (outputValue, 0, 255, 0, 100);
// change the analog out value:
analogWrite(pwmOutPin, outputValue);
}