Changing code for RGY led to BI-colour

Hi All im new to Arduino and am struggling to change some code. im trying to make a LED target system that I have found but it uses RGY leds I would like to use 2 Lead bi-colour Leds instead.

I have tried changing the code myself but I don't understand coding enough to make it work.

Also I will not be using the potentiomiter that is in this code and not sure if I can just remove that line of text?

Hopefully someone can help and thanks in advance.

/*
Airsoft Target System - by Manuel Palmeira
This system uses piezos and RGY LEDs. For more information on this project and the circuit please check out the
instructibles page.

Feel free to use and change this code. Just don't use it to exploit others.
Since I just need simple colors (the 3 primary ones with the LED), I've coded the colors in a ON/OFF base.
If you want to have more color variations make sure to connect the LEDs to PWM pins and change the values on the
color functions according to the color that you want.
*/

//setting the pins for the LED interface
const int Led1yellowPin = 10;
const int Led1redPin = 9;
const int Led1greenPin = 8;
const int Led2yellowPin = 7;
const int Led2redPin = 6;
const int Led2greenPin = 5;
const int Led3yellowPin = 4;
const int Led3redPin = 3;
const int Led3greenPin = 2;
 
//uncomment this line if using a Common Anode LED
//#define COMMON_ANODE

//setting the pins for the piezos input.
const int HeadSensor = A0;
const int TorsoSensor = A1;
const int LegSensor = A2;

//setting the pins for the potentiometer
int potPin = A3;

//Adjust this value to change the sensitivity of the piezos
//const int THRESHOLD = 25;

// these variables will change:
int HeadSensorReading = 0;      // variable to store the value read from the sensor pin
int TorsoSensorReading = 0;      // variable to store the value read from the sensor pin
int LegSensorReading = 0;      // variable to store the value read from the sensor pin
int HeadSensorReadingRandom = 0;      // variable to store the value read from the sensor pin
int TorsoSensorReadingRandom = 0;      // variable to store the value read from the sensor pin
int LegSensorReadingRandom = 0;      // variable to store the value read from the sensor pin
int RandomON = 0;              //variable to count the shots required to enter competition mode
int RandomOFF = 0;             //variable to count the shots required to exit competition mode
int RandomTarget = 0;          //variable to decide the next target
int RandomTime = 0;          //variable to decide the delay until next random target
int hit = 0;                //variable to tell if the right target was hit
unsigned long StartTime;       //variable to know when the target started to be active
unsigned long ActualTime;       //variable to know what time it is
unsigned long Timeout;       //variable to know if the target has been active for too long
int sensitivity = 0;       // variable to store the value coming from the sensor
 
void setup()
{
  //set the LED pins as outputs
  pinMode(Led1yellowPin, OUTPUT);
  pinMode(Led1redPin, OUTPUT);
  pinMode(Led1greenPin, OUTPUT);
  pinMode(Led2yellowPin, OUTPUT);
  pinMode(Led2redPin, OUTPUT);
  pinMode(Led2greenPin, OUTPUT);
  pinMode(Led3yellowPin, OUTPUT);
  pinMode(Led3redPin, OUTPUT);
  pinMode(Led3greenPin, OUTPUT); 
}
 
void loop()
{
  //standart mode, all targets are red
  setColor(0, 1, 0);  // red

  sensitivity = analogRead(potPin);    // read the value from the potentiometer
  
  // read the sensor and store it in the variable sensorReading:
  HeadSensorReading = analogRead(HeadSensor);
  TorsoSensorReading = analogRead(TorsoSensor);
  LegSensorReading = analogRead(LegSensor);
  
  // if the sensor reading is greater than the threshold:
  if (HeadSensorReading >= sensitivity) {
    // update the LED pin itself:
    digitalWrite(Led1yellowPin, 0);
    digitalWrite(Led1redPin, 0);
    digitalWrite(Led1greenPin, 1);
    delay(300);
    //  one hit for the random mode
    RandomON = RandomON + 1;
  }
  
  // if the sensor reading is greater than the threshold:
  if (TorsoSensorReading >= sensitivity) {
    // update the LED pin itself:
    digitalWrite(Led2yellowPin, 0);
    digitalWrite(Led2redPin, 0);
    digitalWrite(Led2greenPin, 1);
    delay(300);
    //  resets the count for the random mode
    RandomON = 0;
  }
  
  // if the sensor reading is greater than the threshold:
  if (LegSensorReading >= sensitivity) {
    // update the LED pin itself:
    digitalWrite(Led3yellowPin, 0);
    digitalWrite(Led3redPin, 0);
    digitalWrite(Led3greenPin, 1);
    delay(300);
    //  resets the count for the random mode
    RandomON = 0;
  }
  
  //  entered random game mode
  if (RandomON >= 10) {
    RandomON = 0;    //  resets the count for the random mode
    RandomOFF = 0;    //  resets the count for the random mode
    //  you have 10 targets to take out before the game mode ends
    while (RandomOFF < 10) {
      setColor(0, 0, 0);  // lights out
      //delay(100);
      RandomTime = random(500, 2000);  // set a random time to present next target between 500ms and 4s
      RandomTarget = random(1, 4);  // set a random target
      //RandomTarget = 1;  // set a random target
      
      switch (RandomTarget) {
        case 1:
          StartTime = millis();    //  start timer
          hit = 0;  // reset the number of times the target has been hit. you have 3 shots until it moves to the next one
          delay(RandomTime);
          while(hit < 3){
            //  read sensors for random mode
            HeadSensorReadingRandom = analogRead(HeadSensor);
            TorsoSensorReadingRandom = analogRead(TorsoSensor);
            LegSensorReadingRandom = analogRead(LegSensor);
            //  light the target to hit
            digitalWrite(Led1yellowPin, 1);
            digitalWrite(Led1redPin, 0);
            digitalWrite(Led1greenPin, 0);
            ActualTime = millis();  // measure the actual time
            Timeout = ActualTime - StartTime;   // calculate the time that has passed since the target was active
            // if the sensor reading is greater than the threshold:
            if (HeadSensorReadingRandom >= sensitivity) {
              // update the LED pin itself:
              wright(3);
              hit = 3;
            }         
            // if the sensor reading is greater than the threshold:
            if (TorsoSensorReadingRandom >= sensitivity || LegSensorReadingRandom >= sensitivity) {
              // update the LED pin itself:
              wrong(3);
              hit = hit + 1;
            }
            //if the target has been active for too long (more than 20s), you've timed out
            if (Timeout >= 20000) {
              wrong(3);
              hit = 3;
            }
          }
          //  one less target to the end of random mode
          RandomOFF = RandomOFF + 1;
          break;
          
        case 2:
          StartTime = millis();    //  start timer
          hit = 0;  // reset the number of times the target has been hit. you have 3 shots until it moves to the next one
          delay(RandomTime);
          while(hit < 3){
            //  read sensors for random mode
            HeadSensorReadingRandom = analogRead(HeadSensor);
            TorsoSensorReadingRandom = analogRead(TorsoSensor);
            LegSensorReadingRandom = analogRead(LegSensor);
            //  light the target to hit
            digitalWrite(Led2yellowPin, 1);
            digitalWrite(Led2redPin, 0);
            digitalWrite(Led2greenPin, 0);
            ActualTime = millis();  // measure the actual time
            Timeout = ActualTime - StartTime;   // calculate the time that has passed since the target was active
            // if the sensor reading is greater than the threshold:
            if (TorsoSensorReadingRandom >= sensitivity) {
              // update the LED pin itself:
              wright(3);
              hit = 3;
            }   
            // if the sensor reading is greater than the threshold:
            if (HeadSensorReadingRandom >= sensitivity || LegSensorReadingRandom >= sensitivity) {
              // update the LED pin itself:
              wrong(3);
              hit = hit + 1;
            }
            //if the target has been active for too long (more than 20s), you've timed out
            if (Timeout >= 20000) {
              wrong(3);
              hit = 3;
            }
          }
          //  one less target to the end of random mode
          RandomOFF = RandomOFF + 1;
          break;
          
        case 3:
          StartTime = millis();    //  start timer
          hit = 0;  // reset the number of times the target has been hit. you have 3 shots until it moves to the next one
          delay(RandomTime);
          while(hit < 3){
            //  read sensors for random mode
            HeadSensorReadingRandom = analogRead(HeadSensor);
            TorsoSensorReadingRandom = analogRead(TorsoSensor);
            LegSensorReadingRandom = analogRead(LegSensor);
            //  light the target to hit
            digitalWrite(Led3yellowPin, 1);
            digitalWrite(Led3redPin, 0);
            digitalWrite(Led3greenPin, 0);
            ActualTime = millis();  // measure the actual time
            Timeout = ActualTime - StartTime;   // calculate the time that has passed since the target was active
            // if the sensor reading is greater than the threshold:
            if (LegSensorReadingRandom >= sensitivity) {
              // update the LED pin itself:
              wright(3);
              hit = 3;
            } 
            // if the sensor reading is greater than the threshold:
            if (HeadSensorReadingRandom >= sensitivity || TorsoSensorReadingRandom >= sensitivity) {
              // update the LED pin itself:
              wrong(3);
              hit = hit + 1;
            }
            //if the target has been active for too long (more than 20s), you've timed out
            if (Timeout >= 20000) {
              wrong(3);
              hit = 3;
            }
          }
          //  one less target to the end of random mode
          RandomOFF = RandomOFF + 1;
          break;
      }
    }
  }
}

//easy way to set the color on the LEDs 
void setColor(int yellow, int red, int green)
{
  #ifdef COMMON_ANODE
    yellow = 1 - yellow;
    red = 1 - red;
    green = 1 - green;
  #endif
  digitalWrite(Led1yellowPin, yellow);
  digitalWrite(Led1redPin, red);
  digitalWrite(Led1greenPin, green);
  digitalWrite(Led2yellowPin, yellow);
  digitalWrite(Led2redPin, red);
  digitalWrite(Led2greenPin, green);
  digitalWrite(Led3yellowPin, yellow);
  digitalWrite(Led3redPin, red);
  digitalWrite(Led3greenPin, green);
}

//function to flash green light
void wright(int TimesFlashWright)
{ 
  for (int x = 0; x <= 3; x++) {
    setColor(0,0,1);
    delay(50);
    setColor(0,0,0);
    delay(50);
  }
}

//function to flash red light
void wrong(int TimesFlashWrong)
{
  for (int x = 0; x <= TimesFlashWrong; x++) {
    setColor(0,1,0);
    delay(50);
    setColor(0,0,0);
    delay(50);
  }
}

There are several types of bi-color LEDs, requiring different wiring, so post a link to the product page for the one you have.

Here you can just remove the analogRead and slip in your own setting as a constant.

     sensitivity = 512;    // set the sensitivity to 1/2

sensitivity cou,d range from 0 to 1023 if you had the pot in there, so use numbers in that range as you test.

Or. You could come to a better understanding of the roll of sensitivity and just code that area differently.

HTH

a7

these are the ones I ordered in red/green 5mm

thanks A7 I'll give that a go then change the value as needed

Bit of an update I have stripped the code right back to just one pezo and 1 led and taken out the random mode.

I have managed to get the led to light green when the target is hit but it will not light red when not being triggered any ideas?

#include <BiColorLED.h>
//the pins -> red and green indicate positive connection pin for that colour
BiColorLED led=BiColorLED(4,5); // (pin 1, pin 2)


 
//uncomment this line if using a Common Anode LED
#define COMMON_ANODE

//setting the pins for the piezos input.
const int HeadSensor = A0;

//Adjust this value to change the sensitivity of the piezos
//const int THRESHOLD = 25;

// these variables will change:
int HeadSensorReading = 0;      // variable to store the value read from the sensor pin
int HeadSensorReadingRandom = 0;      // variable to store the value read from the sensor pin
int hit = 0;                //variable to tell if the right target was hit
unsigned long StartTime;       //variable to know when the target started to be active
unsigned long ActualTime;       //variable to know what time it is
unsigned long Timeout;       //variable to know if the target has been active for too long
int sensitivity = 0;       // variable to store the value coming from the sensor
 
void setup() {
led.setColor(1);
led.setColor2(2);
}
 
void loop()
{
  //standart mode, all targets are red
  led.setColor(0, 1);  // red

  sensitivity = 1000;    // set the sensitivity to 1/2
  
  // read the sensor and store it in the variable sensorReading:
  HeadSensorReading = analogRead(HeadSensor);
  
  
  // if the sensor reading is greater than the threshold:
  if (HeadSensorReading >= sensitivity) {
    // update the LED pin itself:
    led.setColor(1, 0);
    delay(300);
    }

}

What's the difference? A bi-colour led can display red, green or yellow, so you could call that an "RGY" led. How are the "RGY" LEDs that the code was written for different to the LEDs you want to use now?

The rgy led have 4 leads where as the bi-colour i have are only 2

Never heard of those before. Why would anyone make an led with red, green any yellow chips in it? You can so easily make yellow by illuminating red and green together!

Do you ever want the led to light yellow?

If not, I would suggest not using that library. I think it is confusing you.

Try

  led.setColor(1);  // red
...
  led.setColor(2); // green

For a 2 pin bi-color led, i actually use just simply a voltage divider between 5v & GND (220R & 330R but the values may vary a tad depending on the LED and which leg you connect) and connect one pin(leg) of the LED halfway between the 2 resistors. Connect the other leg to The IO pin of the arduino.
Setting the pin 'HIGH' will light up 1 color, setting it 'LOW' will light up the other color, and setting the pinMode to INPUT will turn the LED off.

Thanks i dont need yellow so will give that a go

That bicolor LED has only two leads, so to get each color you have to reverse the direction of current flow. Does the library do that?

Yes, I reviewed the library code (there's not much of it). If you want yellow, you need to call it's .drive() method frequently (i.e. no use of delay()) and it will reverse the current flow each time.

im so close to getting somewhere then get stopped again
I can now make 1 target light red then green when hit that's fine now when I add the 2nd and 3rd target they stay on red and do not change when hit?

/*
Airsoft Target System - by Manuel Palmeira
This system uses piezos and RGY LEDs. For more information on this project and the circuit please check out the
instructibles page.

Feel free to use and change this code. Just don't use it to exploit others.
Since I just need simple colors (the 3 primary ones with the LED), I've coded the colors in a ON/OFF base.
If you want to have more color variations make sure to connect the LEDs to PWM pins and change the values on the
color functions according to the color that you want.
*/

//the pins -> red and green indicate positive connection pin for that colour
const int green1 = 4;
const int red1 = 5;
const int green2 = 6;
const int red2 = 7;


 
//setting the pins for the piezos input.
const int HeadSensor = A0;
const int TorsoSensor = A1;


//Adjust this value to change the sensitivity of the piezos
//const int THRESHOLD = 25;

// these variables will change:
int HeadSensorReading = 0;      // variable to store the value read from the sensor pin
int TorsoSensorReading = 0;      // variable to store the value read from the sensor pin
int hit = 0;                //variable to tell if the right target was hit
unsigned long StartTime;       //variable to know when the target started to be active
unsigned long ActualTime;       //variable to know what time it is
unsigned long Timeout;       //variable to know if the target has been active for too long
int sensitivity = 0;       // variable to store the value coming from the sensor
 
void setup() 
{
  pinMode(red1, OUTPUT);
  pinMode(green1, OUTPUT);
  pinMode(red2, OUTPUT);
  pinMode(green2, OUTPUT);
}
 
void loop()
{
  // red on
  digitalWrite(red1, HIGH);
  digitalWrite(green1, LOW);
  digitalWrite(red2, HIGH);
  digitalWrite(green2, LOW);

  sensitivity = 1;    // set the sensitivity to 1/2
  
  // read the sensor and store it in the variable sensorReading:
  HeadSensorReading = analogRead(HeadSensor);
  TorsoSensorReading = analogRead(TorsoSensor);
  
  // if the sensor reading is greater than the threshold:
  if (HeadSensorReading >= sensitivity) {
    // update the LED pin itself:
    digitalWrite(red1, LOW);
  digitalWrite(green1, HIGH);
  delay(500);
}
  
  // if the sensor reading is greater than the threshold:
  if (TorsoSensorReading >= sensitivity) {
    // update the LED pin itself:
    digitalWrite(red2, LOW);
  digitalWrite(green2, HIGH);
  delay(500);
  }  
}

Swap the sensor pins, but do not change the wiring:

//setting the pins for the piezos input.
const int HeadSensor = A1;
const int TorsoSensor = A0;

Which led works correctly now?

that worked then swapped back and worked the other way I think I had a bad connection.

the issue I have now is adding the random feature back in.

I have added the code for the random changed the led pins but im getting an error when trying to verify the code.

error: 'wright' was not declared in this scope

all I have done here to the original code is add ninth pin outs for the leds not sure why I have this?

/*
Airsoft Target System - by Manuel Palmeira
This system uses piezos and RGY LEDs. For more information on this project and the circuit please check out the
instructibles page.

Feel free to use and change this code. Just don't use it to exploit others.
Since I just need simple colors (the 3 primary ones with the LED), I've coded the colors in a ON/OFF base.
If you want to have more color variations make sure to connect the LEDs to PWM pins and change the values on the
color functions according to the color that you want.
*/

//the pins -> red and green indicate positive connection pin for that colour
const int green1 = 4;
const int red1 = 5;
const int green2 = 6;
const int red2 = 7;
const int green3 = 2;
const int red3 = 3;


//setting the pins for the piezos input.
const int HeadSensor = A0;
const int TorsoSensor = A1;
const int LegSensor = A2;


// these variables will change:
int HeadSensorReading = 0;      // variable to store the value read from the sensor pin
int TorsoSensorReading = 0;      // variable to store the value read from the sensor pin
int LegSensorReading = 0;      // variable to store the value read from the sensor pin
int HeadSensorReadingRandom = 0;      // variable to store the value read from the sensor pin
int TorsoSensorReadingRandom = 0;      // variable to store the value read from the sensor pin
int LegSensorReadingRandom = 0;      // variable to store the value read from the sensor pin
int RandomON = 0;              //variable to count the shots required to enter competition mode
int RandomOFF = 0;             //variable to count the shots required to exit competition mode
int RandomTarget = 0;          //variable to decide the next target
int RandomTime = 0;          //variable to decide the delay until next random target
int hit = 0;                //variable to tell if the right target was hit
unsigned long StartTime;       //variable to know when the target started to be active
unsigned long ActualTime;       //variable to know what time it is
unsigned long Timeout;       //variable to know if the target has been active for too long
int sensitivity = 0;       // variable to store the value coming from the sensor
 
void setup()
{
  pinMode(red1, OUTPUT);
  pinMode(green1, OUTPUT);
  pinMode(red2, OUTPUT);
  pinMode(green2, OUTPUT);
  pinMode(red3, OUTPUT);
  pinMode(green3, OUTPUT);
}

 
void loop()
{
  //standart mode, all targets are red
   digitalWrite(red1, HIGH);
  digitalWrite(green1, LOW);
  digitalWrite(red2, HIGH);
  digitalWrite(green2, LOW);
  digitalWrite(red3, HIGH);
  digitalWrite(green3, LOW);

  sensitivity = 2;    // set the sensitivity to 1/2
  
  // read the sensor and store it in the variable sensorReading:
  HeadSensorReading = analogRead(HeadSensor);
  TorsoSensorReading = analogRead(TorsoSensor);
  LegSensorReading = analogRead(LegSensor);
  
  // if the sensor reading is greater than the threshold:
  if (HeadSensorReading >= sensitivity) {
    // update the LED pin itself:
    digitalWrite(red1, LOW);
  digitalWrite(green1, HIGH);
  delay(500);
    //  one hit for the random mode
    RandomON = RandomON + 1;
  }
  
  // if the sensor reading is greater than the threshold:
  if (TorsoSensorReading >= sensitivity) {
    // update the LED pin itself:
     digitalWrite(red2, LOW);
  digitalWrite(green2, HIGH);
  delay(500);
    //  resets the count for the random mode
    RandomON = 0;
  }
  
  // if the sensor reading is greater than the threshold:
  if (LegSensorReading >= sensitivity) {
    // update the LED pin itself:
    digitalWrite(red3, LOW);
  digitalWrite(green3, HIGH);
  delay(500);
    //  resets the count for the random mode
    RandomON = 0;
  }
  
  //  entered random game mode
  if (RandomON >= 10) {
    RandomON = 0;    //  resets the count for the random mode
    RandomOFF = 0;    //  resets the count for the random mode
    //  you have 10 targets to take out before the game mode ends
    while (RandomOFF < 10) {
      digitalWrite(red1, LOW);
  digitalWrite(green1, LOW);
  digitalWrite(red2, LOW);
  digitalWrite(green2, LOW);
  digitalWrite(red3, LOW);
  digitalWrite(green3, LOW);  // lights out
      //delay(100);
      RandomTime = random(500, 2000);  // set a random time to present next target between 500ms and 4s
      RandomTarget = random(1, 4);  // set a random target
      //RandomTarget = 1;  // set a random target
      
      switch (RandomTarget) {
        case 1:
          StartTime = millis();    //  start timer
          hit = 0;  // reset the number of times the target has been hit. you have 3 shots until it moves to the next one
          delay(RandomTime);
          while(hit < 3){
            //  read sensors for random mode
            HeadSensorReadingRandom = analogRead(HeadSensor);
            TorsoSensorReadingRandom = analogRead(TorsoSensor);
            LegSensorReadingRandom = analogRead(LegSensor);
            //  light the target to hit
            digitalWrite(red1, HIGH);
            digitalWrite(green1, LOW);
            ActualTime = millis();  // measure the actual time
            Timeout = ActualTime - StartTime;   // calculate the time that has passed since the target was active
            // if the sensor reading is greater than the threshold:
            if (HeadSensorReadingRandom >= sensitivity) {
              // update the LED pin itself:
              wright(green1, HIGH);
              wright(red1, LOW)
              hit = 3;
            }         
            // if the sensor reading is greater than the threshold:
            if (TorsoSensorReadingRandom >= sensitivity || LegSensorReadingRandom >= sensitivity) {
              // update the LED pin itself:
              wrong(green1, LOW);
              wrong(red1, HIGH);
              hit = hit + 1;
            }
            //if the target has been active for too long (more than 20s), you've timed out
            if (Timeout >= 20000) {
              wrong(green1, LOW);
              wrong(red1, HIGH);
              hit = 3;
            }
          }
          //  one less target to the end of random mode
          RandomOFF = RandomOFF + 1;
          break;
          
        case 2:
          StartTime = millis();    //  start timer
          hit = 0;  // reset the number of times the target has been hit. you have 3 shots until it moves to the next one
          delay(RandomTime);
          while(hit < 3){
            //  read sensors for random mode
            HeadSensorReadingRandom = analogRead(HeadSensor);
            TorsoSensorReadingRandom = analogRead(TorsoSensor);
            LegSensorReadingRandom = analogRead(LegSensor);
            //  light the target to hit
            digitalWrite(red2, HIGH);
            digitalWrite(green2, LOW);
            ActualTime = millis();  // measure the actual time
            Timeout = ActualTime - StartTime;   // calculate the time that has passed since the target was active
            // if the sensor reading is greater than the threshold:
            if (TorsoSensorReadingRandom >= sensitivity) {
              // update the LED pin itself:
              wright(green2, HIGH);
              wright(red2, LOW);;
              hit = 3;
            }   
            // if the sensor reading is greater than the threshold:
            if (HeadSensorReadingRandom >= sensitivity || LegSensorReadingRandom >= sensitivity) {
              // update the LED pin itself:
              wrong(green2, LOW);
              wrong(red2, HIGH);
              hit = hit + 1;
            }
            //if the target has been active for too long (more than 20s), you've timed out
            if (Timeout >= 20000) {
              wrong(green2, LOW);
              wrong(red2, HIGH);
              hit = 3;
            }
          }
          //  one less target to the end of random mode
          RandomOFF = RandomOFF + 1;
          break;
          
        case 3:
          StartTime = millis();    //  start timer
          hit = 0;  // reset the number of times the target has been hit. you have 3 shots until it moves to the next one
          delay(RandomTime);
          while(hit < 3){
            //  read sensors for random mode
            HeadSensorReadingRandom = analogRead(HeadSensor);
            TorsoSensorReadingRandom = analogRead(TorsoSensor);
            LegSensorReadingRandom = analogRead(LegSensor);
            //  light the target to hit
            digitalWrite(red3, HIGH);
            digitalWrite(green3, LOW);
            ActualTime = millis();  // measure the actual time
            Timeout = ActualTime - StartTime;   // calculate the time that has passed since the target was active
            // if the sensor reading is greater than the threshold:
            if (LegSensorReadingRandom >= sensitivity) {
              // update the LED pin itself:
             wright(green3, HIGH);
             wright(red3, LOW);
              hit = 3;
            } 
            // if the sensor reading is greater than the threshold:
            if (HeadSensorReadingRandom >= sensitivity || TorsoSensorReadingRandom >= sensitivity) {
              // update the LED pin itself:
              wrong(green3, LOW);
              wrong(red3, HIGH);
              hit = hit + 1;
            }
            //if the target has been active for too long (more than 20s), you've timed out
            if (Timeout >= 20000) {
              wrong(3);
              hit = 3;
            }
          }
          //  one less target to the end of random mode
          RandomOFF = RandomOFF + 1;
          break;
      }
    }
  }
}
  
  

Looks like there is some other code you forgot to add.

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