Microcontroller › AVR › imu sensor mpu 6050 help › i have done that thing also
i have done that thing also nothing is wrong with the lcd …
this is my actual code:
here is my code:
#include<avr/io.h> //This is the header for AVR Microcontroller.
#define F_CPU 12000000UL
#include “i2cmaster.h”
#include<util/delay.h>
#include”lcd118010.h” //lcd
#define mpu 0X68 //address of the i2c device
int main(void)
{
unsigned char ret=0;
DDRC=0X00;
PORTC=0X00; //disabling the internal pull up for sda,scl
lcd_init();
i2c_init(); //initialise i2c communication
while(1)
{
lcd_string(“hi “);
_delay_ms(1000);
ret=i2c_rep_start(mpu); //send adress to recognize slave device and if ret=0 device is accesible ret=1 device is not accessible
lcd_showvalue(ret); //print that value on lcd
_delay_ms(1900);
lcd_clear(); //clear lcd & continue
}
}
[/CODE]
my observations :lcd is printing “hi” but, ret value is not printing(neither 1 nor 0) and neither is lcd clearing.
“””but if i am commenting ret=i2c_rep_start(mpu); “”””
then only lcd clears & rexecutes the loop
how do i solve this problem? is my sensor ok!!
[CODE]
#include<avr/io.h> //This is the header for AVR Microcontroller.
#define F_CPU 12000000UL
#include “i2cmaster.h”
#include<util/delay.h>
#include”lcd118010.h” //lcd
#define mpu 0X68 //address of the i2c device
int main(void)
{
unsigned char ret=0;
DDRC=0X00;
PORTC=0X00; //disabling the internal pull up for sda,scl
lcd_init();
i2c_init(); //initialise i2c communication
while(1)
{
lcd_string(“hi “);
_delay_ms(1000);
ret=i2c_rep_start(mpu); //send adress to recognize slave device and if ret=0 device is accesible ret=1 device is not accessible
lcd_showvalue(ret); //print that value on lcd
_delay_ms(1900);
lcd_clear(); //clear lcd & continue
}
}
[/CODE]
my observations :lcd is printing “hi” but, ret value is not printing(neither 1 nor 0) and neither is lcd clearing.
“””but if i am commenting ret=i2c_rep_start(mpu); “”””
then only lcd clears & rexecutes the loop
how do i solve this problem? is my sensor ok!!