]> Devi Nivas Git - gt-ece4180-lab02.git/commitdiff
Fix up/down adjustment for g
authorAdvaith Menon <83835839+advaithm582@users.noreply.github.com>
Fri, 19 Sep 2025 15:21:37 +0000 (11:21 -0400)
committerAdvaith Menon <83835839+advaithm582@users.noreply.github.com>
Fri, 19 Sep 2025 15:21:37 +0000 (11:21 -0400)
02-I2CIMU/02-I2CIMU.ino

index c83b16964b60d7fdb088b4965c8585e4732f3759..425f0ef590dad382194168ba0ebae578181c5e74 100644 (file)
@@ -11,7 +11,7 @@
 
 #define NUM_LEDS 1
 #define LED_PIN 8 /* TODO */
-#define GOOD_VAL 1000
+#define GOOD_VAL 2000
 
 #define I2C_ADDR ICM_20948_I2C_ADDR_AD1
 #define CLOCKF 400000
@@ -118,7 +118,7 @@ void setup() {
     ICM_20948_low_power(&imu, false);
 
     pixel.begin();
-    pixel.setBrightness(100);
+    pixel.setBrightness(50);
 }
 
 
@@ -145,6 +145,8 @@ void color_change(int16_t x, int16_t y, int16_t z) {
     uint16_t xa, ya, za;
     int16_t co; // chosen one
     struct color c;
+
+    z = z - 16000;
     /* find direction */
     xa = (x < 0) ? -x : x;
     ya = (y < 0) ? -y : y;
@@ -154,12 +156,15 @@ void color_change(int16_t x, int16_t y, int16_t z) {
     if (xa >= GOOD_VAL) {
         curr_col = 0;
         co = x;
+        Serial.println("X AXIS");
     } else if (ya >= GOOD_VAL) {
         curr_col = 1;
         co = y;
+        Serial.println("Y AXIS");
     } else if (za >= GOOD_VAL) {
         curr_col = 2;
         co = z;
+        Serial.println("Z AXIS");
     }
 
     curr_dir = (co < 0) ? 1 : 0;