Problem with microbit and sensors

Hello,
Am using microbit v1.5 and ir sensor (tcrt5000), in P3 and vcc=3.3v.
the problem is when the ir sensor detects and sends the value 1 to pin3, this value always remains 1 in the event of no-detection, whereas normally it returns to the value 0.
knowing that sometimes this problem fails.
Any solution please?

Hi @mr.oussama ,

Can you provide a little more information? In particular:

  1. Can you share a link to the project? (See instructions to create a share link)
  2. Are you using a module that has a tcrt5000 or just a plain tcrt5000? If a module, what module? If not, can you share a diagram or description of how it’s wired?
  3. It looks like the tcrt5000 should be used with a “pull resistor” to avoid a floating input. A floating input can cause the type of behavior you have described. Some sensor modules may already have a pull resistor on them. If there isn’t a pull resistor, the micro:bit pins can also use an internal pull resistor. The choice of pull (up or down) will depend on overall wiring and code. There are blocks to configure pulls in the Advanced section of tool boxes. Go to Pins and the ... more toolbox (description of block here).