User`s manual

mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
The following code demonstrates use of library procedure ShortToStr. Example
prints the converted value to LCD display.
program test
dim txt as char[20]
dim i as short
main:
PORTB = 0
' initial value for portb
TRISB = 0
' designate portb as output
Lcd_Init(PORTB)
' initialize LCD on portb
Lcd_Cmd(PORTB, LCD_CLEAR)
' send command 'clear display'
LCD_Cmd(PORTB, LCD_CURSOR_OFF)
' send command 'cursor off'
txt = "mikroElektronika"
' assign text
LCD_Out(PORTB,1,1,txt)
' print txt, 1st row, 1st col
Delay_ms(1000)
txt = "testing.."
' write string to txt
LCD_Out(PORTB,2,1,txt)
Delay_ms(1000)
' print txt, 2nd row, 1st col
Lcd_Cmd(PORTB,LCD_CLEAR)
for i = 127 to -111 step -1
ShortToStr(i,txt)
' convert variable i to string
LCD_Out(PORTB,2,1,txt)
' print i (string value)
Delay_ms(100)
Lcd_Cmd(PORTB,LCD_CLEAR)
next i
txt = "The End"
LCD_Out(PORTB,1,1,txt)
end.
MikroElektronika:
Development
tools
-
Books
-
Compilers
mikroBASIC
making it simple...
165
page
Example