Skip to main content
added 85 characters in body
Source Link

I am currently working on a project where i take a frequency, and i want the code to take that value and use a formula to work out its mmh2O level. I use the Serial Monitor to input the values, but i have a problem. When writing the values e.g. "44.62352548","44.49151522". The value that is sent is wrong and displayed wrong. enter image description here

I know the code i have written does not support this many signigicant figures from a float. And i have tried a few things to try and solve it but i cannot crack it.

I have tried using dtostrf() command, but i have never used this before and dont understand. Somebody from the arduino Forums had helped me out but it didnt seem to work. I have also tried formatting aswell, and that did not seem to work.

If anyone has any help and advice it would be much appreciated.

float level;
float myValue;

String msg1 = "Enter Frequency (type 0 to exit): "; 
String msg2 = "Your Frequency is: ";

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  Serial.print(msg1);

  while (Serial.available() == 0);
  {
     
  }
  myValue = Serial.parseFloat();
  if (myValue == 0.0)
  {
    Serial.end();
  }
  else
  { 
    freqConversion();
  }
}

 void freqConversion()
{
  level = (myValue-44.712)/-0.0285493333;
  Serial.println(myValue);
  Serial.print(msg2);
  Serial.println(level);
}

I am currently working on a project where i take a frequency, and i want the code to take that value and use a formula to work out its mmh2O level. I use the Serial Monitor to input the values, but i have a problem. When writing the values e.g. "44.62352548","44.49151522". The value that is sent is wrong and displayed wrong.

I know the code i have written does not support this many signigicant figures from a float. And i have tried a few things to try and solve it but i cannot crack it.

I have tried using dtostrf() command, but i have never used this before and dont understand. Somebody from the arduino Forums had helped me out but it didnt seem to work. I have also tried formatting aswell, and that did not seem to work.

If anyone has any help and advice it would be much appreciated.

float level;
float myValue;

String msg1 = "Enter Frequency (type 0 to exit): "; 
String msg2 = "Your Frequency is: ";

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  Serial.print(msg1);

  while (Serial.available() == 0);
  {
     
  }
  myValue = Serial.parseFloat();
  if (myValue == 0.0)
  {
    Serial.end();
  }
  else
  { 
    freqConversion();
  }
}

 void freqConversion()
{
  level = (myValue-44.712)/-0.0285493333;
  Serial.println(myValue);
  Serial.print(msg2);
  Serial.println(level);
}

I am currently working on a project where i take a frequency, and i want the code to take that value and use a formula to work out its mmh2O level. I use the Serial Monitor to input the values, but i have a problem. When writing the values e.g. "44.62352548","44.49151522". The value that is sent is wrong and displayed wrong. enter image description here

I know the code i have written does not support this many signigicant figures from a float. And i have tried a few things to try and solve it but i cannot crack it.

I have tried using dtostrf() command, but i have never used this before and dont understand. Somebody from the arduino Forums had helped me out but it didnt seem to work. I have also tried formatting aswell, and that did not seem to work.

If anyone has any help and advice it would be much appreciated.

float level;
float myValue;

String msg1 = "Enter Frequency (type 0 to exit): "; 
String msg2 = "Your Frequency is: ";

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  Serial.print(msg1);

  while (Serial.available() == 0);
  {
     
  }
  myValue = Serial.parseFloat();
  if (myValue == 0.0)
  {
    Serial.end();
  }
  else
  { 
    freqConversion();
  }
}

 void freqConversion()
{
  level = (myValue-44.712)/-0.0285493333;
  Serial.println(myValue);
  Serial.print(msg2);
  Serial.println(level);
}
deleted 35 characters in body
Source Link

I am currently working on a project where i take a frequency, and i want the code to take that value and use a formula to work out its mmh2O level. I use the Serial Monitor to input the values, but i have a problem. When writing the values e.g. "44.62352548","44.49151522". The value that is sent is wrong and displayed wrong.

I know the code i have written does not support this many signigicant figures from a float. And i have tried a few things to try and solve it but i cannot crack it.

I have tried using dtostrf() command, but i have never used this before and dont understand. Somebody from the arduino Forums had helped me out but it didnt seem to work. I have also tried formatting aswell, and that did not seem to work.

If anyone has any help and advice it would be much appreciated.

float level;
float myValue;

String msg1 = "Enter Frequency (type 0 to exit): "; 
String msg2 = "Your Frequency is: ";

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  Serial.print(msg1);

  while (Serial.available() == 0);
  {
     
  }
  myValue = Serial.parseFloat();
  if (myValue == 0.0)
  {
    Serial.end();
  }
  else
  { 
    freqConversion();
  }
}

 void freqConversion()
{
  level = (myValue-44.712)/-0.0285493333;
  Serial.println(myValue);
  Serial.print(msg2);
  Serial.println(level);
  Serial.println(44.62352548, 8);
}

I am currently working on a project where i take a frequency, and i want the code to take that value and use a formula to work out its mmh2O level. I use the Serial Monitor to input the values, but i have a problem. When writing the values e.g. "44.62352548","44.49151522". The value that is sent is wrong and displayed wrong.

I know the code i have written does not support this many signigicant figures from a float. And i have tried a few things to try and solve it but i cannot crack it.

I have tried using dtostrf() command, but i have never used this before and dont understand. Somebody from the arduino Forums had helped me out but it didnt seem to work. I have also tried formatting aswell, and that did not seem to work.

If anyone has any help and advice it would be much appreciated.

float level;
float myValue;

String msg1 = "Enter Frequency (type 0 to exit): "; 
String msg2 = "Your Frequency is: ";

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  Serial.print(msg1);

  while (Serial.available() == 0);
  {
     
  }
  myValue = Serial.parseFloat();
  if (myValue == 0.0)
  {
    Serial.end();
  }
  else
  { 
    freqConversion();
  }
}

 void freqConversion()
{
  level = (myValue-44.712)/-0.0285493333;
  Serial.println(myValue);
  Serial.print(msg2);
  Serial.println(level);
  Serial.println(44.62352548, 8);
}

I am currently working on a project where i take a frequency, and i want the code to take that value and use a formula to work out its mmh2O level. I use the Serial Monitor to input the values, but i have a problem. When writing the values e.g. "44.62352548","44.49151522". The value that is sent is wrong and displayed wrong.

I know the code i have written does not support this many signigicant figures from a float. And i have tried a few things to try and solve it but i cannot crack it.

I have tried using dtostrf() command, but i have never used this before and dont understand. Somebody from the arduino Forums had helped me out but it didnt seem to work. I have also tried formatting aswell, and that did not seem to work.

If anyone has any help and advice it would be much appreciated.

float level;
float myValue;

String msg1 = "Enter Frequency (type 0 to exit): "; 
String msg2 = "Your Frequency is: ";

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  Serial.print(msg1);

  while (Serial.available() == 0);
  {
     
  }
  myValue = Serial.parseFloat();
  if (myValue == 0.0)
  {
    Serial.end();
  }
  else
  { 
    freqConversion();
  }
}

 void freqConversion()
{
  level = (myValue-44.712)/-0.0285493333;
  Serial.println(myValue);
  Serial.print(msg2);
  Serial.println(level);
}
Source Link

Problems with inputting into serial monitor

I am currently working on a project where i take a frequency, and i want the code to take that value and use a formula to work out its mmh2O level. I use the Serial Monitor to input the values, but i have a problem. When writing the values e.g. "44.62352548","44.49151522". The value that is sent is wrong and displayed wrong.

I know the code i have written does not support this many signigicant figures from a float. And i have tried a few things to try and solve it but i cannot crack it.

I have tried using dtostrf() command, but i have never used this before and dont understand. Somebody from the arduino Forums had helped me out but it didnt seem to work. I have also tried formatting aswell, and that did not seem to work.

If anyone has any help and advice it would be much appreciated.

float level;
float myValue;

String msg1 = "Enter Frequency (type 0 to exit): "; 
String msg2 = "Your Frequency is: ";

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  Serial.print(msg1);

  while (Serial.available() == 0);
  {
     
  }
  myValue = Serial.parseFloat();
  if (myValue == 0.0)
  {
    Serial.end();
  }
  else
  { 
    freqConversion();
  }
}

 void freqConversion()
{
  level = (myValue-44.712)/-0.0285493333;
  Serial.println(myValue);
  Serial.print(msg2);
  Serial.println(level);
  Serial.println(44.62352548, 8);
}