Program is printing items not in the code. Need guidance

Hi, I am working on a project which takes the input from an Oxygen sensor and subtracts it to find the difference from the number I have supplied. The issue is that it works for until it triggers the else and then starts printing a v= and that number loops indefinitely. I don't know what is wrong with my code.

I attached my serial monitor below

#include "VernierLib.h" //include Vernier functions in this sketch
VernierLib Vernier; //create an instance of the VernierLib library

float sensorReading; //create global variable to store sensor reading
float gateOpen = 0.36;

void setup() {
Serial.begin(9600); //setup communication to display
Vernier.autoID(); //identify the sensor being used
pinMode(11,OUTPUT); // sets digital pin 11 as output
pinMode(12,OUTPUT); // sets digital pin 12 as output

}

void loop() {
sensorReading = Vernier.readSensor(); //read one data value
Serial.print(sensorReading,2); //print data value
Serial.print(" "); //print a space
Serial.println(Vernier.sensorUnits()); //print units and skip to next line
delay(1000); //wait 10 seconds

if (sensorReading-gateOpen > 0.01){
digitalWrite(11,HIGH);
digitalWrite(12, LOW);
}
else{
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
}

}

Post the link to the library you are using.

I suspect that you are not running the program you're showing us. Prove it to yourself- add a print to setup and verify that you see it.

There are Serial.print statements in that library( assuming the library at link is one you are using)
29 in total some of them are in a "debug block " or behind comments.
One of them prints "v="

You are using pins 11 and 12 for something:

 pinMode(11,OUTPUT); // sets digital pin 11 as output
  pinMode(12,OUTPUT); // sets digital pin 12 as output
.
.
.

But the library looks to use these pins too, one as an input:

VernierLib::VernierLib()
{
  pinMode(2, INPUT); //Echo pin; this is the pin that goes high when an echo is received 
  pinMode(3, OUTPUT);//Trigger Pin used for Motion Detector
  pinMode(6, OUTPUT);// set up DCU lines, assuming it is on Digital 2
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT); //multiplexer on the shield, lsb
  pinMode(11, OUTPUT); //multiplexer on the shield, msb
  pinMode (12, INPUT_PULLUP); //button on DCU 
  pinMode (13, OUTPUT); //LED on shield
 }

You're changing 11 which is used for a "multiplexer on the shield". You've made pin 12 an output but the vernier library suggests it's used for a pushbutton:

_buttonState = digitalRead(12);// button on shield
    // check if the pushbutton is pressed.
    // if it is, the buttonState is HIGH:
    if (_buttonState == LOW) // button down
    {. . .

So what are you doing with pins 11 and 12?

Blackfin:
You are using pins 11 and 12 for something:

 pinMode(11,OUTPUT); // sets digital pin 11 as output

pinMode(12,OUTPUT); // sets digital pin 12 as output
.
.
.




But the library looks to use these pins too, one as an input:



VernierLib::VernierLib()
{
  pinMode(2, INPUT); //Echo pin; this is the pin that goes high when an echo is received
  pinMode(3, OUTPUT);//Trigger Pin used for Motion Detector
  pinMode(6, OUTPUT);// set up DCU lines, assuming it is on Digital 2
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT); //multiplexer on the shield, lsb
  pinMode(11, OUTPUT); //multiplexer on the shield, msb
  pinMode (12, INPUT_PULLUP); //button on DCU
  pinMode (13, OUTPUT); //LED on shield
}




You're changing 11 which is used for a "multiplexer on the shield". You've made pin 12 an output but the vernier library suggests it's used for a pushbutton:



_buttonState = digitalRead(12);// button on shield
    // check if the pushbutton is pressed.
    // if it is, the buttonState is HIGH:
    if (_buttonState == LOW) // button down
    {. . .




So what are you doing with pins 11 and 12?

I am using pin 11 to trigger a relay to open a ball valve to allow oxygen to flow in and pin 12 triggers the relay to close the ball valve

arduino_new:
Post the link to the library you are using.

jdrev:
GitHub - VernierST/VernierLib: Library to make reading Vernier sensors used on a Vernier Interface Shield easy.

That library is very poorly written.
-pinmode() in constructor.
-incorrectly setting value of char array.
-incorrectly(maybe) doing math with integers.

arduino_new:
That library is very poorly written.
-pinmode() in constructor.
-incorrectly setting value of char array.
-incorrectly(maybe) doing math with integers.

What would you recommend I do to fix it. If I just use one output it does trigger and turn the led on and off. It's once I add that second output that I'm getting the problem with the repeating numbers that aren't accurate (blowing carbon dioxide onto the sensor and the value still doesn't change)

Use different pins; analogue pins can be used for digital IO.
2)
Rewrite the library to fix the issues.

arduino_new:
That library is very poorly written.
-pinmode() in constructor.
-incorrectly setting value of char array.
-incorrectly(maybe) doing math with integers.

What is wrong with using pinmode() in a constructor, The fact that the pin numbers are hardwired/named or the concept in general?

The constructor could be called before the Arduino hardware setup is initialized,
so the pinMode could be undone by the initialization.

Whandall:
The constructor could be called before the Arduino hardware setup is initialized,
so the pinMode could be undone by the initialization.

I understand what you say
But is that only a problem if user makes a mistake like assign the same GPIO number to two different task in the setup()?
Is that correct or is there another scenario where it can cause a issue?

typematrix:
I understand what you say

Obviously you don't.

pinMode (or any other hardware interaction) could be undone, like it never happend.

I see no connection to your strange quenstions.