Need help on how to approch 12v digital read on a blinking signal

what is an optiresistor?
and edit for my original post
i need it to read 1 value(possibly analog) when it is solid positive+++++++. and another when it is varriable+-+-+-+-+-+-+-+,--+--+--+--+ or ---++---++---++ etc. and the read low or 0 if its analog when its constant neg ---------
can i take an average of 10 or 20 read values(or more?), and take an average(or the most often or mode)? so 111111 would yeild 1, and 101010101 would yeild 0.5, and 00000 would yeild 0?
would that have errors, and how would you code that?