How to let propeller chip distinguish what I have already input though a keyboard?
daniel ding
Posts: 52
[FONT= ]Hi everyone
I have use a lcd.out(key.newkey) command to display the keyboard input. now I want to let the propeller distinguish what the lcd is displaying.
For one, if I press the "g" key on keyboard and lcd display a "g" charactor, and the chip know taht I input a "g" charactor ,and if I press enter key next the chip will light a led.
more I want to add a number after charactor "g" to decide the frequency of the led light.
thanks
daniel[/FONT]
I have use a lcd.out(key.newkey) command to display the keyboard input. now I want to let the propeller distinguish what the lcd is displaying.
For one, if I press the "g" key on keyboard and lcd display a "g" charactor, and the chip know taht I input a "g" charactor ,and if I press enter key next the chip will light a led.
more I want to add a number after charactor "g" to decide the frequency of the led light.
thanks
daniel[/FONT]
Comments
If you have lots of different conditions and sequences you may want to draw out a state machine for your tasks and code that up instead.
thanks for ur reply, but you know the"key.newkey" is a number of ASCII.
the command of you gave key_input=="g"????
also need a display of "g" the same time do something
In your example you can directly take the keyboard-input and send it to the LCD.
And as the propeller tool also creates ASCII-characters (at least for the number range defined by ASCII) you can also compare the keyboard-input with the single character in the code:
key_input == 'g'
And it will be true if you entered a g and id will be false if you entered something else.
To output the entered key you simply add:
key_input := key.newkey
lcd.out( key_input )
...
The point is that you have to store the key input somewhere if you want to do 2 things with it. In your example from the begining you send the key.newkey directly to the lcd and then it's gone. Now way to check the content afterwards - except reading it back from LCD, which is a lot of overhead.