ASCII code to character

General discussion on mikroBasic for AVR.
Post Reply
Author
Message
lipo2907
Posts: 1
Joined: 17 Oct 2007 23:34

ASCII code to character

#1 Post by lipo2907 » 17 Oct 2007 23:53

Hello,

I´m new in programing, Please help me, i´m try to convert ASCII code to character.
I´m reciving a ASCII code from USART and send as character to a LCD.
I using the following code, but i keep reciving the error message:
"Syntax Erro: Expected 'constant' but 'variable' found"

program lcd4_USART

'dim texto as string[16]
dim c as char[16]

main:

Lcd_Init(PORTC, 5, 4, PORTC, LCD_LO_NIBBLE)
Lcd_Out(1,1,"ATmega32")
Lcd_Out(2,1,"test")

USart1_Init(9600)
Delay_ms(10) ' wait for module to set
Usart1_Write_Text("ATmega32 test")

while true
while USart1_Data_Ready=0
wend
USart1_Write_Char(USart1_Read)
' ByteToStr(USart1_Read, texto)
c = Chr(USart1_Read)
' Lcd_Out(1,1,texto)
Lcd_Out(1,1,c)
wend

end.

Thanks

Basic
Posts: 6
Joined: 27 Nov 2007 12:48

#2 Post by Basic » 27 Nov 2007 12:50

no reply ? :oops: I need reason 4 my project too ... :idea:

zuran
Posts: 29
Joined: 19 Oct 2007 08:15
Location: Belgium

#3 Post by zuran » 27 Nov 2007 21:18

reply is very easy.

It is not implemented yet
but if it works with a constant it should be easy to make it work with an variable, so maybe bug or ...

You have to implement it on your own

I used this to convert ASCII from uart to int

Code: Select all

sub function chrtoint(dim charac as byte) as byte
    result = charac - 48
end sub
you can make an array with A-Z and convert on your own

Post Reply

Return to “mikroBasic for AVR General”