Skip to main content
stmmm
Associate II
March 8, 2023
Question

How to store user input in a variable?

  • March 8, 2023
  • 1 reply
  • 1738 views

I am working with a Nucleo-L476RG and I am using PuTTY as an interface using UART. I am trying to use PuTTY to read a numerical value from the user and then store that entered value in a variable. Below is how I am initializing UART to receive user input. As it is right now, if I type a number or letter on my keyboard it will ready the value correctly, but I want to type a 6 digit number and then verify that number against a separate 6 digit number that will already be defined in the code and then see if they match, like a password. How do I use UART to read 6 numerical values and store them in a separate variable?0693W00000aIWF8QAO.png

This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
March 8, 2023

You'd have to wait on the input of data, collecting characters, constructing a string, and determining how the user terminates that input, with say a RETURN/ENTER key stroke.

You can then take the string and process it with sscanf() or atoi() type commands, or parse it with string commands.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..