AnalogRead+mapping ans decimal.

i no understand this analog Read functino good i have code analogRead A0 and then i mapping this to 0,1023 to 2-14 (ph value)
and potentiometer move come ok, o-1023 is 2-14 this is ok, but how i change value ?
now out come serial monitor full number only one decimal, mean out come only 2-14.
but how change code come out 2,1 or 5,3 or 12,6 one decimal more ?

some say to me other forum use float but i no understand all float anythink, i no need calculate this other numbers i need only this map to 2-14 and more decimal. how ?

sorry my bad englsih but finnis local section this forum no have help, and others net no have finnish language help, englsih not have good for me.

masavee:
i no understand this analog Read functino good i have code analogRead A0 and then i mapping this to 0,1023 to 2-14 (ph value)
and potentiometer move come ok, o-1023 is 2-14 this is ok, but how i change value ?
now out come serial monitor full number only one decimal, mean out come only 2-14.
but how change code come out 2,1 or 5,3 or 12,6 one decimal more ?

some say to me other forum use float but i no understand all float anythink, i no need calculate this other numbers i need only this map to 2-14 and more decimal. how ?

sorry my bad englsih but finnis local section this forum no have help, and others net no have finnish language help, englsih not have good for me.

Try:

PH = map(analogRead(A0),0,1023,20,140);
Serial.print(PH / 10);
Serial.print(",");
Serial.println(PH % 10);

Don't use map(). You don't need it, and for what you're doing, it won't help you.
Just do the arithmetic.
Maybe this would work for you:

// get the reading
int rawReading = analogRead(A0);

// calculate the pH
float pHValue = ((rawReading / 1023.0) * 12.0) + 2.0;

// output
Serial.print("raw reading: ");
Serial.print(rawReading, DEC);
Serial.print("   pH: ");
Serial.println(pHValue, 1);  // one decimal place

@odometer:
Your way:

Sketch uses 3,888 bytes (12%) of program storage space. Maximum is 30,720 bytes.
Global variables use 222 bytes (10%) of dynamic memory, leaving 1,826 bytes for local variables. Maximum is 2,048 bytes.

My way:

Sketch uses 2,732 bytes (8%) of program storage space. Maximum is 30,720 bytes.
Global variables use 206 bytes (10%) of dynamic memory, leaving 1,842 bytes for local variables. Maximum is 2,048 bytes.

For the same result. :slight_smile:

outsider:
@odometer:
Your way:

Sketch uses 3,888 bytes (12%) of program storage space. Maximum is 30,720 bytes.
Global variables use 222 bytes (10%) of dynamic memory, leaving 1,826 bytes for local variables. Maximum is 2,048 bytes.

My way:

Sketch uses 2,732 bytes (8%) of program storage space. Maximum is 30,720 bytes.
Global variables use 206 bytes (10%) of dynamic memory, leaving 1,842 bytes for local variables. Maximum is 2,048 bytes.

For the same result. :slight_smile:

I don't know: does the OP then want to use that pH for any further calculations?

Excellent Q.