I´m trying to read 1.000 V at A0 (analog input) wjth 12 bits resolution, multiply by a factor of 1.625 and output it at DAC1 but it doesn't work. The sketch follows, please help me. Thanks a lot.
/*
Read the value of the potentiometer (1.000V) at A0 and multiply
for 1.625 and output it at DAC1 both with 12 bits resolution
*/
float val = 0; // variable to store the value coming from A0
float val2 = 0;
float outputValue =0;
int ananalogInPin = 0; // Analog input pin connected to the variable resistor
void setup()
{
// nothing in setup
}
void loop() {
val = analogRead(analogInPin); // read the voltage on the pot
analogReadResolution(12);
val2=val*1.625;
analogWriteResolution(12);
outputValue = map(val2,0,1023,0,4095);
analogWrite(1,outputValue); //write at DAC1
}