Yamber
Newbie level 5
- Joined
- May 6, 2013
- Messages
- 8
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,330
Hi all,
I'm very new in Programming. I would like to realize a project using an Lm032 LCD, A SHT11 Humidity Sensor, PIC18f2620 (mplab, Proteus). I went through the device datasheet and I wrote the following code. But the result is terrible. I need assistance please.
Tnx in advance.
I'm very new in Programming. I would like to realize a project using an Lm032 LCD, A SHT11 Humidity Sensor, PIC18f2620 (mplab, Proteus). I went through the device datasheet and I wrote the following code. But the result is terrible. I need assistance please.
Tnx in advance.
Code:
//#include <stdio.h>
//#include <stdlib.h>
#include "HUMIDITY.h"
#include <delays.h>
void DelayXLCD (void);
void Delay18ForTCY (void);
void DelayPORXLCD (void);
void init_XLCD (void);
char humidity = 0;
int temperature = 0;
void delay_1s (void);
//void delay_s (void);
int main (void){
char data ;
//TRISC = 0xFF;
OSCCON = 0x76;
init_XLCD();
putrsXLCD ("SYSTEM READY");
__delay_ms(60);
WriteCmdXLCD(0x01);
OpenI2C (MASTER, SLEW_OFF);
SSPADD = 45;
/***********************/
IdleI2C ();
StartI2C ();
while (SSPCON2bits.SEN);
__delay_ms(90);
while(1){
RestartI2C ();
IdleI2C();
WriteI2C (0x03);
IdleI2C ();
temperature = ReadI2C ();
IdleI2C ();
AckI2C ();
__delay_ms(1);
WriteI2C (0x05);
IdleI2C();
humidity = ReadI2C();
IdleI2C();
NotAckI2C ();
__delay_ms(1);
StopI2C ();
// LATB = ReadI2C ();
putrsXLCD (" Temp= ");
putrsXLCD (humidity);
putrsXLCD (" ");
// SetDDRamAddr (0x40);
// putrsXLCD("RH =");
// putrsXLCD(humidity);
// putrsXLCD(" ");
}
}
void delay_s (void){
int i;
for (i =0; i < 20; i++)
__delay_ms(50);
}
void init_XLCD (void) {
OSCCON = 0x76;
OpenXLCD(FOUR_BIT & LINES_5X7);
while (BusyXLCD());
WriteCmdXLCD(0x06); //Move right don't shift
WriteCmdXLCD(0x0C); //Display On
WriteCmdXLCD(CURSOR_OFF);
WriteCmdXLCD(0x01); // Clear Screen
}
void DelayXLCD (void){
Delay1KTCYx (20);
}
void DelayFor18TCY( void ){
Delay10TCYx(20);
}
void DelayPORXLCD (void){
Delay1KTCYx (60);
}