Hi , i saw this video : www.youtube.com/watch . I want to know if i could use esp32 c3 instead of what you are using in the video . In this case , can you specify the pin diagram in order to connect to mpu6050 ?.
Below is the image of my connection (esp32 C3) with MPU6050
Code is :
#include <MPU6050_light.h>
MPU6050 mpu(Wire);
unsigned long timer = 0;
#include <BleMouse.h>
BleMouse bleMouse;
#define btnL 2
#define btnR 1
#define btnM 3
#include <Wire.h>
#define SDA 9
#define SCL 10
#define AD0 11
#define INT 12
void setup() {
pinMode(btnR,INPUT);
pinMode(btnL,INPUT);
pinMode(btnM,INPUT);
pinMode(INT, INPUT); //int goes high when activity is detected(wakeup?)
pinMode(AD0, OUTPUT);
digitalWrite(AD0, LOW);//sets I2C adress
delay(50);
Serial.begin(115200);
Wire.begin(SDA,SCL);
Serial.println("Starting BLE work!");
bleMouse.begin();
byte status = mpu.begin();
Serial.print(F("MPU6050 status: "));
Serial.println(status);
while(status!=0){ } // stop everything if could not connect to MPU6050
Serial.println(F("Calculating offsets, do not move MPU6050"));
delay(2000);
// mpu.upsideDownMounting = true; // uncomment this line if the MPU6050 is mounted upside-down
mpu.calcOffsets(); // gyro and accelero
Serial.println("Done!\n");
}
void loop() {
if(bleMouse.isConnected()) {
clicking();
mpu.update();
int x = map(mpu.getAngleX(),-90,90,10,-10);
int y = map(mpu.getAngleY(),-90,90,-10,10);
int z = map(mpu.getAngleZ(),-90,90,-10,10);
bleMouse.move(x,y);
if((millis()-timer)>10){ // print data every 10ms
Serial.print("X : ");
Serial.print(mpu.getAngleX());
Serial.print(x);
Serial.print("\tY : ");
Serial.print(mpu.getAngleY());
Serial.print(y);
Serial.print("\tZ : ");
Serial.println(mpu.getAngleZ());
Serial.print(z);
timer = millis();
}
}
}
void clicking(){
bool Lclick = digitalRead(btnL);
bool Mclick = digitalRead(btnM);
bool Rclick = digitalRead(btnR);
if (Lclick == 0){
bleMouse.click(MOUSE_LEFT);
}
if (Rclick == 0){
bleMouse.click(MOUSE_RIGHT);
}
if (Mclick == 0){
bleMouse.click(MOUSE_MIDDLE);
}
}