hi everyone,
i'm new to electronics. i've been trying to get my microcontroller (atmel at89s51) to read readings from a LDR. i have a LED light source that feeds light to the LDR and will be interrupted by black stripes (well, simply speaking, an encoder).
so what i'm doing now is passing a 5v to the LDR and have the LDR control a NPN transistor, then have the output of transistor directed back to my controller.
now the problem is that i get voltages that are within the threshold value of the controller, and it causes my controller to read random values.
i've searched online and found out that i'll either need comparator or a schmitt trigger. from what i'm reading (wiki), it seems like a schmitt trigger is a better option. is this correct?
i'm new to electronics. i've been trying to get my microcontroller (atmel at89s51) to read readings from a LDR. i have a LED light source that feeds light to the LDR and will be interrupted by black stripes (well, simply speaking, an encoder).
so what i'm doing now is passing a 5v to the LDR and have the LDR control a NPN transistor, then have the output of transistor directed back to my controller.
now the problem is that i get voltages that are within the threshold value of the controller, and it causes my controller to read random values.
i've searched online and found out that i'll either need comparator or a schmitt trigger. from what i'm reading (wiki), it seems like a schmitt trigger is a better option. is this correct?