Converting a number to ascii character
Archiver
Posts: 46,084
I am using the Basic stamp 2 and I was wondering how I can convert a
number ie. 50 to Ascii 5 and 0.
I need to display a counter decreasing from 60 seconds down to 0 on
an LCD display
Thank you
-M
number ie. 50 to Ascii 5 and 0.
I need to display a counter decreasing from 60 seconds down to 0 on
an LCD display
Thank you
-M
Comments
display, you have to do a bit of work:
char = (seconds DIG 1) + 48 : GOSUB LCD_Write
char = (seconds DIG 0) + 48 : GOSUB LCD_Write
The '+ 48' is what converts a single-digit value to its ASCII code. If you
have a serial LCD, you can user built-in formatting:
SEROUT pin, baud, [noparse][[/noparse]DEC2 seconds]
-- Jon Williams
-- Parallax
In a message dated 5/16/2003 7:44:52 PM Central Standard Time,
mdbware@h... writes:
> I am using the Basic stamp 2 and I was wondering how I can convert a
> number ie. 50 to Ascii 5 and 0.
> I need to display a counter decreasing from 60 seconds down to 0 on
> an LCD display
>
> Thank you
>
> -M
[noparse][[/noparse]Non-text portions of this message have been removed]
I found the solution on one of the postings, this is what I did.
for Index = 2 to 0
char=(t1 dig iNDEX) + "0"
gosub lcdWr
next
Thank you
-M
--- In basicstamps@yahoogroups.com, jonwms@a... wrote:
> Depends on the kind of LCD you have: parallel or serial. For a
parallel
> display, you have to do a bit of work:
>
> char = (seconds DIG 1) + 48 : GOSUB LCD_Write
> char = (seconds DIG 0) + 48 : GOSUB LCD_Write
>
> The '+ 48' is what converts a single-digit value to its ASCII
code. If you
> have a serial LCD, you can user built-in formatting:
>
> SEROUT pin, baud, [noparse][[/noparse]DEC2 seconds]
>
> -- Jon Williams
> -- Parallax
>
>
> In a message dated 5/16/2003 7:44:52 PM Central Standard Time,
> mdbware@h... writes:
>
> > I am using the Basic stamp 2 and I was wondering how I can
convert a
> > number ie. 50 to Ascii 5 and 0.
> > I need to display a counter decreasing from 60 seconds down to 0
on
> > an LCD display
> >
> > Thank you
> >
> > -M
>
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]