NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Project Help and Ideas » Interactive LCD (laptop <=> MC device)
April 14, 2009 by ueharaa |
Hello all, I just wanted to share my first Nerdkits project. It's a small project that I hope will be useful as a starting place for command line interface for future projects. This is my first project, so I offer my experience without any guarantees of anything working :) Test: To communicate with my device. I want to open a program/command prompt and type something and have the LCD display it. Details: software requirements:
wiring requirements: I followed the nerdkits setup for the temperature sensor and , make sure you can copy(burn?) your program to your device. First Test: first test your connection to your device by running (you can also use putty in serial mode)
if everything is hooked up properly you should see your temperature being displayed to console. Second Test: I wrote this code to interact using miniterm.py It takes user input and displays it on the LCD and echos the input back to the console. Typing "q" will send it to it's dying loop. Code:
Other notes: For some reason I get two black spaces on the LCD when I send text to it, not sure what that is. Perhaps someone on this list can help? Hope this helps others interested in having their computer talk to their MC and vice versa. -andy |
---|---|
April 14, 2009 by ueharaa |
sorry about the awful spacing. Not sure what happened, When I originally posted, it did not look that way. -andy PS. Nerdkits, Can someone fix the spacing on the code part, it looks really awful now :( |
April 14, 2009 by mrobbins (NerdKits Staff) |
Just fixed the spacing -- just use a tab or at least four spaces before any code segments and it will do the right thing in the future. As for your two black spaces, my guess is that you are getting a "\r\n" (Windows newline) in there. The fgets(...) function will include its terminating newline, but if your terminal sends a two-character \r\n newline, they'll both get included. I see you tried writing some code to get around this, but maybe you can put something like this right before your fprintf_P(...) statement:
The code block above will go through the buffer and if it finds either newline character, it will replace that with a '\0' to terminate the string there. Also note that I changed your '/0' to a '\0' -- the latter is the correct way to denote a null character, although I think this might be because the forum has a problem with backslashes at the moment! Let me know if that works! Mike |
April 14, 2009 by ranger |
somewhat related... is there a simple way to read the information sent over the serial cable from the tempsensor project? Ideally something from a (linux) terminal. |
April 14, 2009 by wayward |
Assuming you have the serial-to-USB converter and pl2303 driver, then simply reading and writing to and from the special file /dev/ttyUSBx (ttyUSB0 unless you have other serial devices via USB, for example a Palm Pilot via cable) suffices. E.g.:
will spit out the lines from the MCU to your terminal. Accordingly,
and you can send stuff to the MCU. Use your UNIX-fu for the rest. Zoran |
May 26, 2009 by tom8787 |
Great project, was creating something similar. Tnx for posting! |
May 27, 2009 by tom8787 |
@ranger: Read this topic: http://www.nerdkits.com/forum/thread/91/ |
Please log in to post a reply.
Did you know that a microcontroller can measure an RC time constant? Learn more...
|