How can I invert my sensors for my zumo bot?

I'm a fairly new arduino user, and have tried coding a zumo bot with a simple sumo code. The problem I'm having is with the color on my sumo ring. The ring itself is white, and the border is black. My code appears to work for a typical sumo ring, but I do not know how to alter it to adjust for the different colors. Any guidance would be appreciated. Thanks!

Please post your code.

The easier you make it to read and copy your code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

If you get errors when compiling please copy them from the IDE using the "Copy error messages" button and paste the clipboard here in code tags

Have you tried changing the sensor value query from "is smaller" to "is larger"?

I have. I’ve also tried switching them so one is < and the other > but no combination seems to work right.

No help from me until you post your full sketch correctly

I must admit this is the first issue I’ve posted here for help. How exactly do I use code tags to optimize use for the rest of you?

Did you read the advice in the link I posted ?

#include <ZumoShield.h>

#define LED 13

#define QTR_THRESHOLD 2000

#define Reverse_Speed   200
#define Turn_Speed      200
#define Forward_Speed   200
#define R_Duration      200
#define T_Duration      300
int sensorL = 1;
int sensorH = 5;

ZumoMotors Motors;
Pushbutton Button(ZUMO_BUTTON);

#define NUM_SENSORS 6
int sensor_values[NUM_SENSORS];

ZumoReflectanceSensorArray sensors(QTR_NO_EMITTER_PIN);

//Button.waitForButton();


void setup() {
  // put your setup code here, to run once:
  //motors.flipLeftMotor(true);
  //motors.flipRightMotor(true);
  delay(5000);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Button.isPressed())
  {
    Motors.setSpeeds(0, 0);
    Button.waitForRelease();
  }
  sensors.read(sensor_values);

  if (sensor_values[sensorH] > QTR_THRESHOLD)

  {
    Motors.setSpeeds(-Reverse_Speed, -Reverse_Speed);
    delay(R_Duration);
    Motors.setSpeeds(-Turn_Speed, Turn_Speed);
    delay(T_Duration);
    Motors.setSpeeds(Forward_Speed, Forward_Speed);
  }
  if (sensor_values[sensorL] < QTR_THRESHOLD)
  {
    Motors.setSpeeds(-Reverse_Speed, -Reverse_Speed);
    delay(R_Duration);
    Motors.setSpeeds(Turn_Speed, -Turn_Speed);
    delay(T_Duration);
    Motors.setSpeeds(Forward_Speed, Forward_Speed);
  }
  else
  {
    Motors.setSpeeds(Forward_Speed, Forward_Speed);
  }
}

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