How to store user input in a variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-03-08 1:39 PM
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?
- Labels:
-
STM32L4 series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-03-08 3:09 PM
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.
Up vote any posts that you find helpful, it shows what's working..
