 # Calculating The Speed Of Sound with LM35 But It Always Says 0

I'm trying to calculate the speed of sound with LM35 sensor but it always says zero. Can anyone take a look at that code and tell me what is wrong?

``````const int sensor_pin = A0;
const int led = 10;
int sensor_deger = 0;
float sicaklik_deger = 0;
float voltaj_deger = 0;
float ses_hizi ;
float formul ;

void setup() {
pinMode(led , OUTPUT);// put your setup code here, to run once:
Serial.begin(9600);

}

void loop() {
Serial.print("okunan deger = ");
Serial.println(sensor_deger); // put your main code here, to run repeatedly:
voltaj_deger = (sensor_deger / 1023.0 ) * 5000 ;
Serial.print("gelen voltaj = ");
Serial.println(voltaj_deger);
delay(1000);
sicaklik_deger = voltaj_deger / 10;
Serial.print("sicaklik = ");
Serial.println(sicaklik_deger);
float a = sqrt(1 + sicaklik_deger / 273);
ses_hizi = 331 * a;
Serial.println(ses_hizi);
Serial.print("ses hizi = ");
Serial.println(ses_hizi);
formul = 1/ses_hizi;
Serial.print("formul = ");
Serial.println(formul);
}
``````

Here's the code. The formul has to give me the sound of speed with second/meter. But it calculates 0 every time.

Note: sensor_deger means sensor_value sicaklik_deger means temperature value voltaj_deger means voltage value ses_hizi means speed of sound with meter/second and formul means formul which supposed to give me speed of sound with second/meter

I forgot to translate I didn't wrote the code in english.

What do your prints tell you?

temp : 21.15 voltage : 241 speed of sound : 343.52 formul : 0.00

1/ 343.52 =?( to two decimal places)

1/343.52 = 0.00291103865 and then I will multiply by 100 to turn meter to centimeter and then I will divide it by 1000000 to turn second to microsecond so it should give me something like 29.11

But you’re only printing it to two decimal places.
I see no evidence of you multiplying this value by 100

But why does that give me only first two decimal places how can I print all the number?

Have you read the documentation for print/println? Maybe you should.