-I just started Arduino today, and I've already ran into a problem.
-I'm trying to make a mouse glove using an Arduino Pro Micro and an IMU Sensor.
-I've wired everything but the buttons, and whenever I plug in the Arduino to my computer, my normal mouse stops working.
-I need to plug in the Arduino to change the code as the cursor is moving way too fast, but as I said earlier, my mouse won't work, so I can't select the board, and I can't program it.
-How do I fix this?
This is my code:
#include <Wire.h>
#include <Mouse.h>
// Pin definitions
const int rightButtonPin = 5;
const int leftButtonPin = 4;
// Timing for auto-click
unsigned long rightButtonPressTime = 0;
const unsigned long autoClickDelay = 1000; // 1 second hold time
const unsigned long autoClickInterval = 10; // interval between auto clicks (100 cps)
// IMU related variables
const int MPU = 0x68; // MPU-6050 I2C address
int16_t AcX, AcY, AcZ;
float roll, pitch;
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize mouse control
Mouse.begin();
// Initialize button pins
pinMode(rightButtonPin, INPUT_PULLUP);
pinMode(leftButtonPin, INPUT_PULLUP);
// Initialize MPU-6050
Wire.begin();
Wire.beginTransmission(MPU);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
}
void loop() {
}
Yes, this code was written by ChatGPT, because as I said earlier, I am just starting.
I've tried every single USB available, and I even tried using a USB hub, but nothing happened.
Whenever I plug in the Arduino, it stops my normal mouse from moving, and the mouse is on, but the cursor won't really move. It moves, but goes straight back to where it was before in like a millisecond.
Contrary to popular belief ChaGPT should only be used if you know enough to spot when it gives you rubbish. It is not a tool to learn from.
It looks to me like there is some code already running on your Arduino, did you load it in, or was it like that when you got it?
Either way, unplug the Arduino and remove all hardware attached to it.
Then load up the blink sketch, and hold down the reset button while you plug it in, and keep holding it down as you click the upload menu option in the IDE.
Then when you see the bit that says it has finished and gives you the list of memory usages release the reset button. This should give you a blinking LED.
You might have to try this several times before you get it right.
Now, practice loading other stuff from the IDE examples normally. Bin the code you got from ChatGPT as it is total garbage. There is nothing the loop function and so once the code gets started it can never stop.
I didn't know it was going to be difficult, I just thought it would be fun. Also, I don't know anything about Arduino, and I only became interested in learning after everything stopped working.
Thanks for telling me. I'll make sure to remember that.
Most of us regulars look at the Topics page (top of the categories menu), and as we have some very good members around the globe, with some insomniacs, then there are always people ready to answer questions.
Once some one has posted in a topic, they get a notification that there has been an update to that topic.