howlingmadpanda Posted January 26, 2016 Report Share Posted January 26, 2016 For some time I have been working with some more basic electronics projects and have been familiar with electronic theory and the physics behind it. I have now begun working on a geiger counter project, which has gone well for the most part. All of my actual electronics (creating GM tube voltage, detection or ionising radiation) have worked fine. I have only recently, however, begun to work with interfacing an LCD with a PIC18F4550. My intended use of this is to display CPM digitally -- x number of counts in a certain amount of time, display to LCD. I am familiar with PIC Timers, so I didn't think there would be an issue with that code. My issue here is that I attempted to write a "hello world" program on my 16x2 LCD, of course partially skidding the code from online as I had never used an LCD with a PIC before. I know that my PIC is hooked up to the LCD correctly and I am getting current on the pins, implying that a signal is being sent. Could anybody help?Code:<code> #if defined(__XC) #include <xc.h> #elif defined(HI_TECH_C) #include <htc.h> #endif#include <stdint.h> /#include <stdbool.h> #include <xc.h>#include "system.h" #include "user.h" #include <htc.h>#define _XTAL_FREQ 1000000#define rs RA0#define rw RA1#define en RA2//LCD Data pins#define lcdport PORTBvoid lcd_init();void lcdcmd(unsigned char);void lcddata(unsigned char);unsigned char data[20]="hello world";unsigned int i = 0;void main(void){TRISA=0; // Configure Port A as output port//PORTA=0;TRISB=0; // Configure Port B as output port//PORTB=0;lcd_init(); // LCD initializationwhile(data != '\0'){lcddata(data); // Call lcddata function to send characters// one by one from ?data? arrayi++;__delay_ms(300);}}void lcd_init(){lcdcmd(0x38);lcdcmd(0x0C);lcdcmd(0x01);lcdcmd(0x06);lcdcmd(0x80);}void lcdcmd(unsigned char cmdout){lcdport=cmdout;rs=0;rw=0;en=1;__delay_ms(10);en=0;}void lcddata(unsigned char dataout){lcdport=dataout;rs=1;rw=0;en=1;__delay_ms(10);en=0;} </code> Quote Link to comment Share on other sites More sharing options...
ZomBiE80 Posted January 26, 2016 Report Share Posted January 26, 2016 http://www.circuitsgallery.com/2013/09/lcd-interface-with-microcontroller-pic.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.