From 62d206f7927569127e535746ee90281da2ac6db0 Mon Sep 17 00:00:00 2001 From: Andrea Date: Fri, 28 Feb 2025 14:58:48 +0100 Subject: [PATCH] Fix ball detection logic by initializing ballLost to false and updating I2C address for seeker --- src/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f47eefc..c93b0be 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,7 +35,7 @@ OmniWheelMotors motors(MOTOR1_R_PWM, MOTOR1_L_PWM, int lastBallSensor = -1; int lastBallStrength = 255; // Start at max distance unsigned long lastBallDetectionTime = 0; -bool ballLost = true; +bool ballLost = false; void setup() { // Initialize serial communication @@ -158,10 +158,10 @@ void moveBasedOnSensor(int sensorNum, int strength) { } void trackBall() { - // Get IR ball direction from seeker (on I2C address 0x08) - Wire.requestFrom(0x08, 2); - - if (Wire.available() >= 2) { + // Get IR ball direction from seeker (on I2C address 0x10 / 2) + Wire.requestFrom(0x10 / 2, 2); + + if (Wire.available()) { int sensorNum = Wire.read(); // Sensor number (1-12) int strength = Wire.read(); // Strength of the signal (0-255, 0 is closest)