sabin14
Junior Member level 3
- Joined
- Mar 5, 2013
- Messages
- 30
- Helped
- 11
- Reputation
- 22
- Reaction score
- 11
- Trophy points
- 1,288
- Location
- Kerala,India
- Activity points
- 1,431
I am trying to get values form the gyroscopic sensor(MU6060) using I2C and display it directly on lcd using pic 16f877a at 4Mhz.
But not displaying any value on LCD. Please help me to correct the code. The sensor address is 0x69.
But not displaying any value on LCD. Please help me to correct the code. The sensor address is 0x69.
Code:
sbit LCD_RS at RB7_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB1_bit;
sbit LCD_D5 at RB2_bit;
sbit LCD_D6 at RB3_bit;
sbit LCD_D7 at RB4_bit;
sbit LCD_RS_Direction at TRISB7_bit;
sbit LCD_EN_Direction at TRISB5_bit; //lcd configuration
sbit LCD_D4_Direction at TRISB1_bit;
sbit LCD_D5_Direction at TRISB2_bit;
sbit LCD_D6_Direction at TRISB3_bit;
sbit LCD_D7_Direction at TRISB4_bit;
char temp ; //temporary variable
void main(){
PORTB = 0;
TRISB = 0;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_out(1,1,"I2C Value");
I2C1_Init(100000); //set clock frequeny
while(1){
I2C1_Start(); //start I2C
I2C1_Repeated_Start();
I2C1_Wr(0x69);
temp = I2C1_Rd(0); //read value and store it in temp
Lcd_Chr(2,1,temp); //display value read form I2c
I2C1_Stop();
Delay_ms(300);
}
}