Help for Keyboard inputs

Hi,

I have a question about receiving inputs through the serial.read or some other function. Is there a way to input on the computer keyboard a float or number such as 123.12, and record that on the arduino and save it to a variable?

Thanks!

Yes, but I'm not sure what you want to do.

Do you know the serial monitor, part of the Arduino IDE (The arduino software to develop and upload sketches) ? You can type something in the serial monitor, but you can also use another serial program. It is even possible to use the PowerShell in Windows to send data to a serial port.

Do you know the parseFloat() function ? http://arduino.cc/en/Reference/StreamParseFloat It reads the serial input and looks for a floating point number.

Peter_n: Yes, but I'm not sure what you want to do.

Do you know the serial monitor, part of the Arduino IDE (The arduino software to develop and upload sketches) ? You can type something in the serial monitor, but you can also use another serial program. It is even possible to use the PowerShell in Windows to send data to a serial port.

Do you know the parseFloat() function ? http://arduino.cc/en/Reference/StreamParseFloat It reads the serial input and looks for a floating point number.

yes I am using the serial monitor to output streams of data from pressure transmitters and temperature sensors, I am looking for a way to input a number and have that save to a variable (float, double, etc.) that can be used with the data from the sensors to be put into an equation. Is this possible?

Yes, the Arduino can do calculations with 32-bit float number. http://arduino.cc/en/Reference/Float

As an alternative using the Serial object:

#define MAXIN 50
char input[MAXIN];

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

void loop() {
  float val;
  if (Serial.available() > 0) {
    Serial.readBytesUntil('\n', input, MAXIN);
    Serial.print("input = ");
    Serial.print(input);
    val = atof(input);
    Serial.print("   val = ");
    Serial.println(val);
  }
}

Note that the Serial.print() method rounds the data to 2 decimal places, which may not be good enough for you.