Shop OBEX P1 Docs P2 Docs Learn Events
anyone who can tell me how to achieve this function using a 16*2lcd and a keyboard? — Parallax Forums

anyone who can tell me how to achieve this function using a 16*2lcd and a keyboard?

daniel dingdaniel ding Posts: 52
edited 2011-10-02 08:13 in Propeller 1
Hi everyone,

I want to use a 16*2 lcd and a keyboard to achieve the function as follows:

When I input the words “light led6 F1/0” and then press enter key, the led of the pin6 will flash with the
frequently of 1/10.
Who can tell me how to do it.

The lcd and keyboard codes are ready!

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-10-02 07:56
    It's best if you give it a shot on your own. If you run into trouble, post your code, expected results, and actual results.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-10-02 08:13
    That's a complicated task, certainly well beyond the skills of a beginner, particularly if you want to add other commands later. Once you get a line of text from the keyboard, you have to break it down into individual words separated by spaces or the enter key. Then you have to identify the individual words and their meaning (like "light", "led6", "F1/10"). In the case of "led6" and "F1/10", you also have to identify the numeric values and convert them from characters to numbers.

    DongleBasic (in the Propeller Object Exchange) is a Basic interpreter that's easily extended with new statements, written in Spin. It uses the attached PC for its keyboard and display, but could be easily modified to use a PS/2 keyboard and LCD display. It contains routines to read in a line of text, break it up into words or numbers, and process it.

    There are other objects in the Object Exchange that allow you to scan and manipulate strings of text. "Strings" is one. There are others used for GPS output string processing. You'll have to browse through the Object Exchange and look at some of them.

    Note: It's much much easier to use a menu system where each key on the keyboard has a special purpose. "A" might mean "increment the LED pin number". "B" might mean "decrement the LED pin number". "C" would mean "light the LED using the last information entered". "D" would mean "stop". Typing digits would enter the numeric value of the digits. "." would mean "take the last number entered as a fraction". Any non-numeric character would start a new number (by setting the number to zero after using it). The LCD display would always show the current LED pin number, the current number value, and any other useful status information.
Sign In or Register to comment.