Get input from keybpard

I want to build a temperature alarm, and want to set trigger temperature. So I use" scanf " to get input, but my code doesn’t work, It only shows"button2 read". It’s MbedOS6. Thanks very much,


usually is good to make your project simple as can or make an example based on it (when you not want to share your job), where the issues occur. Then others can try the code and try reproduced your issue, but this is not possible with a picture.

However my bet is missing \n in printfs. Your code probably works, but the printf without \n block the output to console. I don’t know if exist another solution, but try to add fflush(stdout); after printfs without \n.

BR, Jan

I think code works, only the input is not displayed on screen as it is being typed, once the Enter-Key is pressed, the code should be processed.

if you want to see your input, then maybe try some program like Serial Monitor in Arduino IDE, it allows you to type in a textbox, before the text is sent upon pressing of enter.

Exactly, but if you want to do a console application with questions/instructions like the above, it doesn’t make sense. Because as user (not like a programmer of that code) you need to know what you have to do, so you need to see the questions/instructions before you will make an answer, otherwise it doesn’t make sense.

BR, Jan

I additional same behavior can be seen in simulator of example of scanf - C++ Reference ( Until you not add fflush(stdout); the instructions will not show.

BR, Jan