Hello,
I'm new to using Arduino and am having some issues with printing the right output to the serial monitor.
My code is as follows:
void setup(){
// Setting up the Serial Monitor
Serial.begin(9600);
Serial.println("What spice do you want?");
}
void loop() {
// Initiates when we receive input from the user
if (Serial.available() > 0){
// Accepting Spice Name
String choice = Serial.readString();
choice.trim();
Serial.println(choice);
// Accepting Spice Quantity
Serial.println("How much would you like?");
int spoons = Serial.parseInt();
Serial.println(spoons);
}
}
So this should accept user input and then print those values out again. For example, if I input choice = "abcd" and spoons = "0.5" it should print as:
"What spice do you want?"
"abcd"
"How much would you like?"
"0.5"
However, the following is the output that is observed:
"What spice do you want?"
"abcd"
"How much would you like?"
"0"
"0.5"
I'm not very sure where the "0" is coming from and I was wondering if y'all had any ideas/suggestions to address it?
Thank you for your time!