how to let propeller chip record the number in decimal I input through a keyboard?
daniel ding
Posts: 52
HI everyone
I want to use a LCD and a keyboard to do a job.
Now the problem is that how to let the chip record a number in decimal which I input use a keyboard。
for one
I input 1,0,0 through a keyboard and display "100" on LCD, now I want let chip know I input a decimal 100 but not a "1". "0"."0".
who can give me some advices.
thanks
daniel
I want to use a LCD and a keyboard to do a job.
Now the problem is that how to let the chip record a number in decimal which I input use a keyboard。
for one
I input 1,0,0 through a keyboard and display "100" on LCD, now I want let chip know I input a decimal 100 but not a "1". "0"."0".
who can give me some advices.
thanks
daniel
Comments
What is the value from the keyboard? ASCII?
Things are not quite so simple in Spin because you need to set up some string space in order to store the characters"1" "0" "0"
Then you need to convert it to a numerical value.
Fortunately, Kye has done all the hard work with a brilliant library of string routines. The routines you could use are "buildstring" and "decimaltointeger". Have a look at the other routines too as they are very useful.
I haven't been following the Propeller forum very closely the last couple of days. (Don't tell anyone, but I've been learning how to program AVR chips.) (I blame Leon.)
Parallax Serial Terminal has a great method that will help. You'll need to copy it into your program since it's a private method.
I hope that helps.
If you're still having problems post the code you have so far.
Duane
Edit: What out for the text that wraps around to the left side of the code window.
thanks for your reply.haha !!
I add your program into the keyboard.spin of parallax library, and use a object of keyboard.spin .
but, it does not work. LCD always display 0,
sth you should know that I am going to use a keyboard PS2 to chip but not the keyboard of the PC.
I see the pst.spin in parallax library, but it can not give me any help.
whatever thanks a lot.
I will show you my program later.
best wishes to u my foreign friend.
I don't know if you can understand me, I want to input a "x" and "y",and let the value of x and y to be a motor‘s coordinates to go with a platform.
I got a big proplem in how to get the value of the x and y through a keyboard.
the codes nest have a lot errors I :frown:think .
Wish you can understand me clearly.
Daniel
I'm not sure where the problem is happening.
If you type "100" into the keyboard, "100" is displayed on the LCD, correct?
I think your:
should work.
Does the LCD object have a "Dec" method?
Can you use:
and have the value of x displayed?
There are easier ways of changing ASCII characters to decimal values but we wont worry about that right now. I think the way you are doing it should work.
Duane
I have already figure it out, you are really a nice guy, thanks very very much to your help.
Now I will transfer the value of x and y to another object, but I really have no idear how to do it.
Daniel from China
thanks a lot to your reply, though I can't understand your codes clearly.
Don't worry if you don't understand what I post. It seems like you are figuring things out whether or not I help.
This is the way I'd use the method "StrToBase" in your program. The ASCII characters are stored in the array keyinput and then the entire array is converted to a number with "StrToBase".
Again, don't worry if you don't see what I'm doing with this code. I just thought I'd show you another way of doing this.
Thanks for your reply soon, I tried your codes and rebuilded my program just now.
But will you imagine what happened?
The value of x and y is displayed 0 in LCD.
Could u tell me why?
next is the codes!