NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » Scanner Input/Output

July 22, 2012
by bl00513
bl00513's Avatar

I'm sure this is in the threads somewhere already, but I cannot seem to find it. I'm trying to figure out how to read and write to/from the terminal. So far I can write to the terminal using

PRINTF(PSTR("some text"))

However, I cannot seem to figure out how to read input back from the user. Is there a simple way to read tokens/text from the user? I appreciate any help!

July 22, 2012
by BobaMosfet
BobaMosfet's Avatar

You haven't provided enough info... read it from where? computer, mcu....? What are you considering the terminal, the LCD? We need context, please.

BM

July 22, 2012
by bl00513
bl00513's Avatar

Sorry, I should have been more specific. I'm using the RX/TX ports and the USB adapter to communicate with my PC's COM port. I'm then connecting to the COM port with putty. I'm hoping to build a menu like interface when the user connects to the device. I just haven't figured out how to capture more than a single character of the user's input.

July 22, 2012
by Ralphxyz
Ralphxyz's Avatar

I just haven't figured out how to capture more than a single character of the user's input.

I assume "user's input" from the PC being captured on the mcu LCD??

Where do you want your "menu like interface" on the mcu lcd or the PC??

It might help you answer your own question if you got more specific in just what you are trying to do, so far I can see why you are having problems.

As generalizations are hard to answer they are just about impossible to program for.

Ralph

July 22, 2012
by bl00513
bl00513's Avatar

I'm trying to setup an interface that the user can access from Putty. I don't need any external components such as the LCD. I just want to setup something like this: 1.) Setup 2.) SMDR 3.) Exit Enter your selection:

I've been able to write to the COM port using

printf(PSTR("some text"));

but I've haven't been able to read more than a single character (using uart_read() )

July 23, 2012
by Rick_S
Rick_S's Avatar

Look in the LED array tutorial on the tutorial page. The source code is there for download. That program takes input from the PC to display on the LED array. You might get some pointers from there. Also, research scanf

Rick

July 23, 2012
by bl00513
bl00513's Avatar

Hey Rick, Thanks for the input. I think scanf is exactly what I was looking for. I found a video tutorial that explains it perfectly.

Post a Reply

Please log in to post a reply.

Did you know that spinning a permanent magnet motor makes a voltage? Learn more...