Thanks for your answer. I plan to use Arduino Uno. Here is a similar schematic
Is there a way to detect, if the LEDs are one without using any other component? Probably not, because the pins to the LEDs can either set to input or output. Not both at the same time.
Think about what you just wrote. The LED was powered and had light. You cut the wire and there is no power to the LED. You can use your program to change the pin from output to input and read the status of that same pin. But what is there to be read? Nothing. Actually is will be undefined because it is now what is referred to as "floating". So the signal could be anything from 0 to 1 or rapidly fluctuating between the two states.
Paul
Thanks, I want the switch to replace by an iron ball. This ball is released manually and starts a stopwatch. Another sensor is detecting falling the ball on a plate and stops the time. It will take about 500 ms.
I don't want to use another pins, because I will need them for further sensors and a display.
@christoph1706, your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem
Addressing your original enquiry, can you tell if the LED is disconnected?
Indeed you can, at least for red LEDs (or any) whose threshold voltage is less than 2 V.
You have the LED connected to ground with a resistor to the I/O pin. Set as OUTPUT, if you write it LOW, the LED is off and if you write it HIGH, the LED is on.
To test whether the LED is present, you set the pin to INPUT_PULLUP. This puts a high value resistance between the pin and 5 V. If the LED is connected, it pulls the pin down to the threshold voltage as the series resistor is much smaller than the internal pullup. This is read as a LOW. If the LED is not connected, then the internal pullup pulls the pin HIGH so you know the LED is no longer there.
You can do this test very fast (microseconds) and promptly go back to whatever state you previously defined as an OUTPUT, there will be no noticeable change in the LED brightness either way.