gonadgranny:
because im using the *0.8 to scale the value and the byte is there because i am trying to save space. i presume that it just truncates the bit after the decimal?
It indeed does. But why not stick to map() here as well?
pos = map(ldrM, 0, 255, 0, 153)
or just int
pos = ldrM * 6 / 10;
Or if 0,6 isn't all that critical... Because he, it's almost just 1/2
pos = ldrM / 2;
gonadgranny:
While im here the reason i have timed the analogRead is because i am trying to save cpu. is it actually necessary for things like that?
Depends on what you want to do and if it troubles the rest if you read it to often. I don't know what you actually do with the ldr reading nor what you do in the rest of the program. From a micro standpoint there is nothing troubling about reading the ADC often other then it takes time. From a human standpoint there is no need to read that often, even the 50 times a second you do now is wayyyyyyy faster then we notice.
gonadgranny:
the reason i chose these max and min values was becuase they were the ones which i detected under very bright light and my finger over the sensor. i dont expect to go above or below those values....
But if it does... If it returns 1023 the map will result in 271
It's on you to decide if this may ever cause a problem. But for example, if you try to store this in a byte it will. To fix this, also add a contrain()
gonadgranny:
i agree, i havent quite mastered the art. are there any tips on choosing good ones as i do confuse myself sometimes.
Rule number 1, don't try to use short names. That might seem nice and fast but it will get you later on because you don't know what it was exactly. So in the case of M, what is M? Does it stand for maped? If so, why is it mapped? Add that instead.
For other variables:
int ldr => const byte LdrPin
int eyes => const byte EyesPin
bool high => bool isSomethingHigh
bool allowed => bool isSomethingAllowed
pos => I don't see you use it as a position, only a brightness (I guess?)