Arduino Forum

Using Arduino => Installation & Troubleshooting => Topic started by: Feargaill on May 21, 2019, 11:51 pm

Title: Device Error
Post by: Feargaill on May 21, 2019, 11:51 pm
I uploaded this code and now get a device error 'Windows has stopped this device because it has reported problems. (Code 43) A request for the USB device descriptor failed.' I uninstalled, reinstalled, updated drivers, tried to roll back driver(not an option). I don't have a reset button either. I don't know what else to do. Arduino: 1.8.9 on Windows 10,

Code: [Select]
#include <MPU9250_asukiaaa.h>
#include <Wire.h>
#include "Mouse.h"
#define accelRange
#define gyroRange

MPU9250 myIMU; //only need yaw/pitch (x,y)


float aX, aY, gX, gY;

void setup() {
  Serial.begin(115200);
  Wire.begin();
 
  myIMU.beginAccel();
  myIMU.beginGyro();
 
  accelRange(0x08); // accel scale 4g; 2g=0x00; 8g=0x10; 16g=0x10
  gyroRange(0x10); // gyro scale 1000 DPD; 250DPS=0x00; 500DPS=0x10; 2000DPS=0x10
  Mouse.begin();
}

void loop() {

  myIMU.accelUpdate();
  aX = myIMU.accelX();
  aY = myIMU.accelY();
 
  myIMU.gyroUpdate();
  gX = myIMU.gyroX();
  gY = myIMU.gyroY();
 
  int total_gX = cos((gX)*cos(gY));
  int total_gY = sin((gX)*cos(gY));
 
  Mouse.move(total_gX, total_gY, 0);
}
Title: Re: Device Error
Post by: BJHenry on May 22, 2019, 04:01 am
What board are you using?
Title: Re: Device Error
Post by: Feargaill on May 22, 2019, 05:13 am
pro micro
Title: Re: Device Error
Post by: pert on May 22, 2019, 05:57 am
Does the problem still occur if you disconnect all wiring/circuitry/components/modules/etc. from your Pro Micro?
Title: Re: Device Error
Post by: Feargaill on May 22, 2019, 06:58 am
I have a mpu9250 soldered, I can't disconnect it
Title: Re: Device Error
Post by: pert on May 22, 2019, 07:53 am
It may be that there is something in the sketch you uploaded that messed up your Pro Micro's USB functionality.

Try this:

File > New

Connect a wire to the reset pin on your Pro Micro and be ready to momentarily connect the other end of that wire to the ground pin.

Sketch > Upload

Watch the black console window at the bottom of the Arduino IDE window until you see something like this:
Code: [Select]
Sketch uses 3462 bytes (12%) of program storage space. Maximum is 28672 bytes.
Global variables use 149 bytes (5%) of dynamic memory, leaving 2411 bytes for local variables. Maximum is 2560 bytes.


Quickly connect the reset pin to ground and then disconnect it.

The upload should now finish successfully and your board should be recognized again. After this, you should be able to go back to uploading to the board normally again. If you upload the problematic sketch it may cause the problem to return. At a glance, I don't see anything about that sketch that would cause a problem. You could try running it without the Mouse library code to narrow down the cause of the error.
Title: Re: Device Error
Post by: Feargaill on May 22, 2019, 05:05 pm
thanks I'll try it
Title: Re: Device Error
Post by: Feargaill on May 30, 2019, 12:04 am
Worked! Thanks Pert
Title: Re: Device Error
Post by: pert on May 30, 2019, 03:42 am
You're welcome. I'm glad to hear it's working now. Enjoy!
Per