![]() Serout 0,0, ' PICBasic Pro, prints “65” Dimensions and Specifications To do accomplish this - that is, to print a variable foo in numeric form - we prefix the variable with a pound sign, as noted above: While this may be desirable for some applications, most would simply want the “65” to print and not it’s ASCII equivalent. Why? Look at an ASCII decimal to character chart - the ASCII representation of the number “65” is ‘A’! Likewise, if foo was 66, a ‘B’ would have been printed, etc. The above example would not print “65” on the display, but merely the ascii character ‘A’ (capital A). Serout 0,0, ' PICBasic Pro, prints ‘A’ character Serout 0,T2400,(foo) ' PICBasic, prints ‘A’ character If you want to print the number inside the variable, you must prefix the variable name with a pound sign (‘#’). ![]() The serout command, when given a variable, will by default print the character which is represented by the number stored in the variable and not the value of the variable itself. In PIC Basic, foo would be declared like so: ![]() Say you have a variable, foo, in which some number is stored. Goto main ' loop Printing Variables in PICBasic and PICBasic Pro Serout PortB.0,0, ' send string “ there you are ” Serout PortB.0,0, ' move the cursor to the 2nd line Serout PortB.0,0, ' send string “Wherever you go” An equivalent program can be written with PIC Basic Pro as follows: main: Serout 0,T2400,(254,192) ' move the cursor to the second line Which notation you choose to use is a matter of preference. Serout 0,T2400,($FE,$C0) ' move the cursor to the second line Could also be written with decimal (base 10) notation as: Hexadecimal is specified by a dollar sign ($) prefix. Note that in the above example, the control codes were written in hexadecimal (base 16). The program will clear the LCD and send the message: “Wherever you go, there you are” at 2400 baud (true mode), wait for two seconds and then loop indefinitely. Serout 0,T2400,(" there you are ") ' send the string “ there you are “ Serout 0,T2400,($FE,$C0) ' move the cursor to the second line Serout 0,T2400,("Wherever you go") ' send the string “wherever you go' ![]() The following PIC Basic program demonstrates sending data and commands to the LCD: Connect the serial input of the LCD to PortB.0 (pin 6) of a PIC Microcontroller. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |