8
\$\begingroup\$

What would be a sensor that I could use to detect if my desktop's CD tray has opened?

There are so many sensors to choose from in the Digikey catalog.

Should I use a mechanical component?

A light beam interference component?

Which one would allow me to detect if my CD tray is open such that the information can be fed into a PIC MCU?

I know I can do a system call for this sort of question, but I would prefer some sort of external sensor.

\$\endgroup\$
0

3 Answers 3

12
\$\begingroup\$

Use a permanent magnet and a reed switch.

Fix the magnet on the moving part and put the reed switch on the fixed part. Then monitor the reed switch with the microcontroller.

\$\endgroup\$
7
\$\begingroup\$

If power consumption isn't an issue (compared to the reed switch), I think I would go with an IR LED and a phototransistor. You could either have it break the beam when it opens or when it's closed and read from the transistor on you digital in pin.

\$\endgroup\$
1
  • \$\begingroup\$ if power is an issue you could pulse the LED at regular intervals and read the phototransistor during the short time the LED is on. 5 pulses per second are more than enough. \$\endgroup\$ Commented Sep 8, 2013 at 9:47
5
\$\begingroup\$

If you don't mind disassembling the drive you could look into the interlock or drive open switch, which should be fairly easy to wire in to. It may even have a pull-up, providing a logic signal directly to your device of choice.

\$\endgroup\$
3
  • \$\begingroup\$ yeah! I feel thats the easiest :) \$\endgroup\$
    – Zaxx
    Commented Nov 23, 2010 at 20:33
  • \$\begingroup\$ and if needed you can use a opto-coupler for reading the signal if you have difference in voltage levels. \$\endgroup\$
    – Zaxx
    Commented Nov 23, 2010 at 20:34
  • \$\begingroup\$ @Zaxx or if you wanted isolation between the computer and another system. \$\endgroup\$
    – Thomas O
    Commented Nov 23, 2010 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.