Page 1 of 1

sending commands using C

Posted: Sat Feb 03, 2007 4:43 pm
by ndyguy
I'm using a LK162-12 and I was wondering if anyone knew how to send commands using C. I've tried

Code: Select all

#define command 0xFE
#define clear_screen 0x58

while(1)
{
......display some text.......
......wait a second.............
printf("%X%X", command, clear_screen);
}
but it just displays them as text. Any suggestions?

Posted: Tue Feb 06, 2007 10:47 am
by Raquel
Hi ndyguy,

Please take a look at this post (I think it will help you out):

http://www.lcdforums.com/forums/viewtopic.php?t=1553

Best Regards,

Posted: Fri Feb 09, 2007 4:11 pm
by ndyguy
Thanks for the response. The link you gave me seems to be focused on opening COM ports in Windows. What I'm looking for is help on sending raw hex (like 0xFE) in C using a microcontroller. I have the micro connected to the LCD and it's displaying text, but I'm not sure of the best way to send hex commands in C. I thought using a printf statement with %X would do the trick, but it just prints the characters as text on the LCD.

Posted: Fri Feb 09, 2007 4:26 pm
by Raquel
What uC are you using?

Posted: Sat Feb 10, 2007 7:36 am
by ndyguy

Posted: Mon Feb 12, 2007 10:49 am
by Raquel
Hi,

On page 149 of the ATmega16 datasheet, there is a good example of transmitting data (hex data). I am not sure if there are any built-in functions in the software/compiler you are using; but the example on the datasheet is generic and works down to the register levels, so there is a small chance of getting it wrong.

Best Regards,