Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ayuda I2C mpu 6050 pic 18f2550
04-06-2015, 01:49 AM,
#1
Ayuda I2C mpu 6050 pic 18f2550
Hola, estoy intentando comunicarme con un giro gy521 ( chip mpu6050) a través de i2c con un pic 18f2550 y la información mostrarla en un lcd 20x4.



LCD Pic 18f2550
RS, E, D4 ~ D8 PIN PIC(2, 3, 4, 5, 6, 7, 0, 0, 0, 0);

MPU6050 Pic 18f2550
Pin ID VDD --> 3.3V on Pi
GND --> GND on Pi
SCL --> SCL pin 1, para 22
SDA --> SDA pin 0, pata 21

Dirección (0x68) o (0X69); // I2C address of MPU6050
frecuencia de I2C 100 khz a 9600

Registro a preguntar :
For MPU-6050:
ACCEL_XOUT_H  register 3B
ACCEL_XOUT_L  register 3C
ACCEL_YOUT_H  register 3D
ACCEL_YOUT_L  register 3E
ACCEL_ZOUT_H  register 3F
ACCEL_ZOUT_L  register 40


Dejo el codigo:

u8 I2C_address = 0x69; //slave address

void setup() {
// put your setup code here, to run once:

//Modo 4 bits, no se emplean los últimos 4 bits
lcd.pins(2, 3, 4, 5, 6, 7, 0, 0, 0, 0); // RS, E, D4 ~ D8

//Indicamos el formato del lcd, en este caso 20x4
lcd.begin(20,4);

//run once:
Wire.begin(0,100); // 0=master mode and 100=100 KHz as bus speed
Serial.begin(9600);
delay(100);
}
void loop() {
u8 c[32]; // length to adapt to your requirement
u8 i;
Wire.requestFrom(I2C_address,32); // here 32 characters as maxi are requested
delay(500);
Serial.printf("\r\n<");
delay(200);
while(!Wire.available());
i=0;
while(Wire.available()) // slave may send less than requested
{
c[i] = Wire.read(); // receive a byte as character
Serial.printf("%c",c[i]); // print the character
i++;
}

delay(1000);
}



Muchas gracias
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)