|
|
View previous topic :: View next topic |
Author |
Message |
that guy Guest
|
displaying values on LCD |
Posted: Fri Feb 27, 2009 2:46 pm |
|
|
I have a PIC 18f4520 that i am using with the PICDEM 2 Plus demo board, the Rohs version. I can output stand text, but now I want to output a value.
Code: |
#include <18F4520.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#define LCD_POWER PIN_D7
#include "Flex_LCD.c"
int num = 0;
//============================
void main()
{
output_high(LCD_POWER); // Turn on power to LCD
output_low(LCD_RW); // Set R/W pin on LCD to a low level
lcd_init(); // Initialize the LCD
lcd_putc('\f');
while(true);
{
lcd_putc(num);
delay_ms(250);
num++;
}
} |
|
|
|
Ttelmah Guest
|
|
Posted: Fri Feb 27, 2009 2:55 pm |
|
|
'num', is a binary value, starting at 0, and incrementing by one each time round the loop. 'putc', outputs a _single_ character. So, your code will print every possible character from 0 to 255.
Look at 'printf', which converts values into their ASCII format for output.
printf("%d\n\r",num);
Read the manual to work out what the other characters here are doing.
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Feb 27, 2009 3:07 pm |
|
|
Also, please don't start a new thread every time you have a new question
about displaying characters on an LCD. You already have an existing
thread on the topic, here:
http://www.ccsinfo.com/forum/viewtopic.php?t=37985
You can add new questions to the existing thread. |
|
|
Guest
|
|
Posted: Fri Feb 27, 2009 3:50 pm |
|
|
I tried the printf command but it is still not working. When I tried the printf it gave me the error STDOUT not defined (may be missing #use rs232). I know C and C++ programming so I understand what the notations are doing, I'm just new to this compiler and just need to get use to it.
Code: | #include <18F4520.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#define LCD_POWER PIN_D7
#include "Flex_LCD.c"
#use rs232 //Do I need this
int num = 0;
//============================
void main()
{
output_high(LCD_POWER); // Turn on power to LCD
output_low(LCD_RW); // Set R/W pin on LCD to a low level
lcd_init(); // Initialize the LCD
lcd_putc('\f');
while(true);
{
printf("%d\n\r",num);
delay_ms(250);
num++;
}
} |
|
|
|
Ttelmah Guest
|
|
Posted: Fri Feb 27, 2009 3:52 pm |
|
|
As I said, _read the manual_.
By default, all commands talk to STDIO. You want to talk to lcd_putc. Look at the entry for printf, and it shows how to do this.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|