This sketch outputs to serial monitor I want to output the voltage to a to a pwm pin.
I can't figure this out.
Program just takes a 0 - 5 v in and maps it to 2.5 v to 5.0v
// map input voltage + or - switch with encoder direction or motor voltage
//float ledPin = 5;
//float outputVoltage;
void setup() {
Serial.begin(9600); // Initialize serial communication
pinMode(ledPin,OUTPUT);
}
// Map input voltage from 0-5V to 2.5-5V
float outputVoltage = map(inputVoltage * 1000, 0, 5000, 2500, 5000) / 1000.0; // Map to millivolts and back to volts
Please read the Arduino/reference to find out how the map function can be use. This way will not do what You want.
Depending on the controller the syntax is "analogWrite( pinNumber, value);" where max value is 255 for some controllers, higher for others.
Make sure to use a pin that provides PWM.