Mpu6050 gyro with led matrix




This is the code:

pixels.Color(0, 0, 255));
    pixels.show();
    delay(200);
  }
  if(g.gyro.y>=-90 && g.gyro.y >=-46){
    pixels.clear();
    pixels.setPixelColor(0, pixels.Color(0, 0, 255));
    pixels.setPixelColor(1, pixels.Color(0, 0, 255));
    pixels.setPixelColor(2, pixels.Color(0, 0, 255));
    pixels.setPixelColor(3, pixels.Color(0, 0, 255));
    pixels.show();
    delay(200);
  }
  if(g.gyro.y<=44 && g.gyro.y>=-44){
   pixels.clear();
   pixels.setPixelColor(10, pixels.Color(0, 0, 255));
    pixels.setPixelColor(9, pixels.Color(0, 0, 255));
    pixels.setPixelColor(5, pixels.Color(0, 0, 255));
    pixels.setPixelColor(6, pixels.Color(0, 0, 255));
    pixels.show();
    delay(200);
  }
}

Also it does this weird thing. It works only if I move it in a way and it goes from 1 row to another, not directly to the 2nd as it should be. And it also works only in one direction. Thanks to anyone who helps.
Uploading: Screenshot_20230805-032403_Video Player.jpg...
Uploading: Screenshot_20230805-032419_Video Player.jpg...

The first if statemenr looks like there's a mishap. Compare with the second one...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.