Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 #include <stdio.h> #include "Helper.h" #include<xc.h> //everything you need for all pics. no need for specific one. typedef unsigned char BYTE; void LCDInit(void ); //Initialize the LCD module per Ocular specifications void Delay(void); void Delay750us(void); void LongDelay(void); void LCDbusy(void); // NOTE: Busy bit does not work, this routine is just a time delay void LCDWriteNibble(BYTE,BYTE); // 1st BYTE is nibble to write with nibble in upper four bits // 2nd BYTE is 0x0 for instruction register, 0x1 for data register void LCDWrite(BYTE); // Write characters to the LCD panel void TextDisplay(unsigned char*, int); // Write a constant string to the LCD void LCDLine1(void); // Set LCD to Line 1 void LCDLine2(void); // Set LCD to Line 2 void ShiftCursor(void); // Shift cursor right by 1 location void CursorOn(void); // Turn on cursor and have it blink void DisplayClr(void); // Clear LCD display #define LCD_PWR LATDbits.LATD7 // LCD power pin #define LCD_EN LATDbits.LATD6 // LCD enable #define LCD_RW LATDbits.LATD5 // LCD read/write line #define LCD_RS LATDbits.LATD4 // LCD register select line #define LCD_EN_DIR TRISDbits.TRISD6 // 6 #define LCD_RW_DIR TRISDbits.TRISD5 // 5 #define LCD_RS_DIR TRISDbits.TRISD4 // 4 void main() { //Let the LCD Module start up // Wait(100); Delay(); //Initialize the LCD Module LCDInit(); //Initialize the ADC Module int ADCInit(); //Clear the Module DisplayClr(); //Write a string at current cursor pos TextDisplay("LM35 Test",9); //LCDWriteStringXY(4,1,"Degree Celcius"); while(1) { int val; //ADC Value int t; //Temperature val=ADCRead(0); //Read Channel 0 t=(val*0.48876);//Convert to Degree Celcius LCDWrite(t);//Prit IT! Wait(); } } //////////////////////////////////////////////////// //Function to send initialization information to LCD //////////////////////////////////////////////////// void LCDInit() { TRISD = 0x00; LCD_PWR=1; // to power up the LCD // These values were obtained from Ocular tech support to properly // initialize the LCD module Delay(); LCDWriteNibble(0x20,0x0); //#1 control sequence (?) Delay750us(); LCDWriteNibble(0x20,0x0); //#2 control sequence (function set 4-bit mode, LCDWriteNibble(0x80,0x0); //#2 control sequence 2-line display with 5x7 dots) Delay750us(); LCDWriteNibble(0x00,0x0); //#3 control sequence (turn display on) LCDWriteNibble(0xC0,0x0); //#3 control sequence Delay750us(); LCDWriteNibble(0x00,0x0); //#4 control sequence (clear display) LCDWriteNibble(0x10,0x0); //#4 control sequence Delay750us(); LongDelay(); LCDWriteNibble(0x00,0x0); //#5 control sequence (return cursor to home position) LCDWriteNibble(0x20,0x0); //#5 control sequence }
I didn't look that closely at your code, but you don't seem to have any I2C function there...
Can you explain please?