10 years, 6 months ago.

photo interrupter KTIR0821 and mbed nxp lpc1768

Hi there

Can anyone identify what is wrong with my code or with my wiring?

I want to get LED glow when I am moving my hand above the photo interrupter

Thanks in advance /media/uploads/brunojkav/--------_2013-11-18_21.04.21.png /media/uploads/brunojkav/2013-11-18_20.44.37.jpg /media/uploads/brunojkav/2013-11-18_20.44.42.jpg /media/uploads/brunojkav/2013-11-18_20.44.52.jpg /media/uploads/brunojkav/2013-11-18_20.44.56.jpg /media/uploads/brunojkav/2013-11-18_20.48.47.jpg

1 Answer

10 years, 6 months ago.

Just copying your code here and putting it between code tags (<<code>> and <</code>>) is easier.

I didn't check your wiring, pins, etc. But for sure there are two errors in your code: First of all you use '='. To check if something is equal always use '=='. Next you use AnalogIn, which returns a value between 0 and 1, so it makes more sense to for example check if it is larger than 0.5.

Also consider just sending the input value back via the PC Serial connection, then you can see which values are read.