photoresistors as input in 4x4 matrix keypad ! is it posible ?????????

Hello to everyone !

was thinking of putting 16 photoresistors in 4x4 matrix and take their data when i put my finger over them so i completely cover the light as a press of a button.

my question is " IS IT POSSIBLE " ????????????????????

if i am correct to a normal 16 btn 4x4 matrix keypad everything is connected to the digital connections, so the microcontroler knows every time on witch input what output is presenting.

photoresistors are analog, the close the circuit all the time ( for a digital input pin ) and an analog input ( witch is the most appropriate input for this project ) can not read digital outputs.

is my thinking correct ?
am i missing something here ?

is there a way to do something like that ?

i was thinking of some analog to digital converters, but everything is a little bit messy in my head at the moment.
can you help me ?

It is VERY possible.
If you choice pullup resistors in according to the photoresistor value (light/dark) you can get digitalsignals you directly can use in your arduino.

BUT the signals become inverse, all buttons give signal except the one you tap on, (thats a software problem)

Go on

Pelle

pelle thank you very much for your reply.

i'll give it a try this weekend !

kourpetis:
and an analog input ( witch is the most appropriate input for this project ) can not read digital outputs.

Not at all correct.
There is nothing to stop you doing a digitalRead() on an analog input. Nor is there anything stopping you doing:

digital = (analogRead(pin) > 512);  //Assume logic 1 if > 50%

You could change the threshold for a the read to something like 128 or even less as you know that it will be almost 0 when the button is pressed, you can't be sure of the value when the button isn't pressed.

Note that because all of the "switches" will be on until you cover one, you will need diodes on each LDR in order for them to be disambiguated.

Two other things - given that the "on" resistance of the LDR is less than about 7k ohm, which would be less than the effective resistance of the internal pull-ups, you can simply use digital reads and use the internal pull-ups.

Finally, you can "charlieplex" a 4 by 4 keypad if you can wire the keys to suit.

Hi, the only problem I can see is if you have a 4 x 4 array to make sure the shadow of your hand when you cover the LDRs in the centre of the array, you will have to choose your threshold well.
Also place a mask over the LDRs so that they have a window over each one,covering the window with your finger will then put the LDR in complete darkness, this will make sure you have a definite covered and uncovered in dull light transition.

Tom.... :slight_smile: