Problem with project

I have problem with diods who doesnt blink , i started with 2 red , 2 yellow , 4 green . I already connected all diods to arduino uno r3 , i use 220Ohm resistors to led diods and i use touch sensor and buzzer and infrared sensor . I need help because if i turn on it all the time buzzer keep making noise and only one red light light , but in project i need the all 2 yellow led still light , green light light then you shoot the ball in front the infra red sensor and i need if i touch the touch sensor then all two red led light need to light i use this code :


//Control 8 LEDs using a touch sensor and ir sensor with buzzer

  int touchsensor = 4;
  int ir = 3;
  int led1=5, led2 =6, led3=7, led4=8, led5=9, led6=10, led7=11, led8=12;
  int buzzer = 2;
  int val=0;

  void setup()
  {
    pinMode(touchsensor, INPUT);
    pinMode(ir, INPUT);
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    pinMode(led3, OUTPUT);
    pinMode(led4, OUTPUT);
    pinMode(led5, OUTPUT);
    pinMode(led6, OUTPUT);
    pinMode(led7, OUTPUT);
    pinMode(led8, OUTPUT);
    pinMode(buzzer, OUTPUT);

  }

  void loop()
{
    if(digitalRead(touchsensor) == 1)
    {
      digitalWrite(led7, HIGH);
      digitalWrite(led8, HIGH);
      tone(buzzer,300,100);
    delay(50);
    }
    else
    {
      digitalWrite(led7, LOW);
      digitalWrite(led8, LOW);
    }
    if(digitalRead(ir) == 0)
    {
      digitalWrite(led3, HIGH);
      digitalWrite(led4, HIGH);
      digitalWrite(led5, HIGH);
      digitalWrite(led6, HIGH);
      tone(buzzer,100,100);
    delay(50);
    }
    else
    {
      digitalWrite(led3, LOW);
      digitalWrite(led4, LOW);
      digitalWrite(led5, LOW);
      digitalWrite(led6, LOW);
      }
    {
      digitalWrite(led1, HIGH);
      digitalWrite(led2, HIGH);
      delay(100);
  } 
}

Please read and use this link: How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum

Thank you for using code tags.
Please show your schematic

Hi, @1marekparek123
Welcome to the forum.

Can you post a link to specs/data of the touch sensor?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Suggest you rename your LEDs in the code, to make a bit more clarity.
led1 could become Red1
led2 could become Red2
etc. etc.
Then we can talk about other improvements. DO NOT MODIFY your first post, simply post your code in a new message when you have modified it.
Thank you, sorry for shouting.

int touchsensor = 4;
int ir = 3;
int yellow1 = 5, yellow2 = 6, green1 = 7, green2 = 8, green3 = 9, green4 = 10, red1 = 11, red2 = 12;
int buzzer = 2;
int val = 0;

void setup() {
  pinMode(touchsensor, INPUT);
  pinMode(ir, INPUT);
  pinMode(yellow1, OUTPUT);
  pinMode(yellow2, OUTPUT);
  pinMode(green1, OUTPUT);
  pinMode(green2, OUTPUT);
  pinMode(green3, OUTPUT);
  pinMode(green4, OUTPUT);
  pinMode(red1, OUTPUT);
  pinMode(red2, OUTPUT);
  pinMode(buzzer, OUTPUT);
}

void loop() {
  // Touch sensor control
  if (digitalRead(touchsensor) == HIGH) {
    digitalWrite(red1, HIGH);
    digitalWrite(red2, HIGH);
    tone(buzzer, 300, 100);
  } else {
    digitalWrite(red1, LOW);
    digitalWrite(red2, LOW);
  }

  // IR sensor control
  if (digitalRead(ir) == LOW) {
    digitalWrite(green1, HIGH);
    digitalWrite(green2, HIGH);
    digitalWrite(green3, HIGH);
    digitalWrite(green4, HIGH);
    tone(buzzer, 100, 100);
  } else {
    digitalWrite(green1, LOW);
    digitalWrite(green2, LOW);
    digitalWrite(green3, LOW);
    digitalWrite(green4, LOW);
  }

  // LED 1 and LED 2 control
  digitalWrite(yellow1, HIGH);
  digitalWrite(yellow2, HIGH);
  
  // Add a small delay to avoid rapid loop execution
  delay(100);
}



if you want i can send you the page i got this project from

touch sensor ttp223

Wow, don't you run out of breath? Let's disassemble that.
you turn the Arduino on(?) wasn't it on when you uploaded the code?
The buzzer is on right away - that means the logic condition is met, so you might want to change that
you need the yellow and green LEDs on to start with - Then write that in the setup
The ball is shot in front of the IR sensor (relevance?) What happens as a result?
and if you hit the touch sensor, the Red LEDs light - for how long? How do you restart the sequence?

I need the yellow diodes to be on all the time
the green ones are meant to light up when detected by the IR sensor and the red diodes with the buzzer should turn on when i touch the touch sensor

i get all this from here : DIY Mini Basketball Game Sensor-Based Arduino Project

yellow - Just set and forget in setup()
When the IR sensor triggers, set the green ones on
When the touch triggers, set the red ones on and turn on the buzzer

Now, you haven't said when you want the red, buzzer, and green to go off. Timeout? Clear button? Reset or power cycle Arduino? All are possible.

timeout

all my work i get from this site : DIY Mini Basketball Game Sensor-Based Arduino Project

Sorry. Plowing through entire projects is not the dream of helpers.
Please extract the information requested and post it here.

For a fee, I'll go dig through that. Pay in advance, take your chances. Otherwise, yes, tell us what you want. I've given a set of hints, why not try to modify the code and if you get stuck, post it back here, IN A NEW MESSAGE PLEASE, NOT IN THE PREVIOUS POSTING, and we can move forward.

how much because i dont have many , and i have very important monday in school where i need to present this project. Then i just need help with this please

Sorry. Time isn't on your side. Won't take it on, then let you down. Ask to have this moved to Jobs and Paid Consultancy - Arduino Forum

i dont want to pay this all i got i just pay for this project already 100 dollars and dont want to spend another money

If you want to try to do it yourself, you could try using Wokwi, because it removes the hardware dependency side:

But again, there's a learning curve, and you'll struggle.