Forum Replies Created
Viewing 1 post (of 1 total)
-
AuthorPosts
-
March 31, 2012 at 4:33 pm in reply to: CHECK OUT MY C PROGRAM ON LCD AS THERE IS LITTLE MISTAKE #7368harpreet khanujaParticipantI AM ENCOUNTER SAME ERROR..PLEASE HELPGOLDITEMP.C(65): warning C206: ‘Lcd_Out’: missing function-prototypeGOLDITEMP.C(65): error C267: ‘Lcd_Out’: requires ANSI-style prototype#include<reg51.h>#include<stdlib.h>//void lcd_data(unsigned char value);// LCD module connectionssbit LCD_RS = P2^0;sbit LCD_EN = P2^1;sbit LCD_D4 = P2^2;sbit LCD_D5 = P2^3;sbit LCD_D6 = P2^4;sbit LCD_D7 = P2^5;// End LCD module connections// OneWire pinoutsbit OW_Bit = P1^2;// end OneWire definition// Set TEMP_RESOLUTION to the corresponding resolution of used DS18x20 sensor:// 18S20: 9 (default setting; can be 9,10,11,or 12)// 18B20: 12const unsigned short TEMP_RESOLUTION = 9;char *text = “000.0000”;unsigned temp;void Display_Temperature(unsigned int temp2write) {const unsigned short RES_SHIFT = TEMP_RESOLUTION – 8;char temp_whole;unsigned int temp_fraction;// check if temperature is negativeif (temp2write & 0x8000) {text[0] = ‘-‘;temp2write = ~temp2write + 1;}// extract temp_wholetemp_whole = temp2write >> RES_SHIFT ;// convert temp_whole to charactersif (temp_whole/100)text[0] = temp_whole/100 + 48;elsetext[0] = ‘0’;text[1] = (temp_whole/10)%10 + 48; // Extract tens digittext[2] = temp_whole%10 + 48; // Extract ones digit// extract temp_fraction and convert it to unsigned inttemp_fraction = temp2write << (4-RES_SHIFT);temp_fraction &= 0x000F;temp_fraction *= 625;// convert temp_fraction to characterstext[4] = temp_fraction/1000 + 48; // Extract thousands digittext[5] = (temp_fraction/100)%10 + 48; // Extract hundreds digittext[6] = (temp_fraction/10)%10 + 48; // Extract tens digittext[7] = temp_fraction%10 + 48; // Extract ones digit// print temperature on LCDLcd_Out(2, 5, text);}void main() {Lcd_Init(); // Initialize LCDLcd_Cmd(_LCD_CLEAR); // Clear LCDLcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor offLcd_Out(1, 1, ” Temperature: “);// Print degree character, ‘C’ for CentigradesLcd_Chr(2,13,223); // different LCD displays have different char code for degree// if you see greek alpha letter try typing 178 instead of 223Lcd_Chr(2,14,’C’);//— main loopdo {//— perform temperature readingOw_Reset(); // Onewire reset signalOw_Write(0xCC); // Issue command SKIP_ROMOw_Write(0x44); // Issue command CONVERT_TDelay_us(120);Ow_Reset();Ow_Write(0xCC); // Issue command SKIP_ROMOw_Write(0xBE); // Issue command READ_SCRATCHPADtemp = Ow_Read();temp = (Ow_Read() << + temp;//— Format and display result on LcdDisplay_Temperature(temp);Delay_ms(500);} while (1);}
-
AuthorPosts
Viewing 1 post (of 1 total)