Calculations

From: ANT_THOMAS21 Nov 2013 21:08
To: ALL1 of 6
For my temperature/light chart I want to change how the light readings are displayed.

Currently 0 = full brightness and 1023 = darkness.

These are just the outputs of the LDR setup. I guess I would prefer if darkness was 1000 to somehow make it a bit easier but it isn't.

What I want to do is somehow invert it and convert into a percentage. So...

Full brightness = 100%
Darkness = 0%

I'll probably want to do this in PHP.

It feels like it shouldn't be too difficult but I currently can't get my head around what is probably some relatively simple maths.


From: Chris Cooper (DEATHTERRAPIN)21 Nov 2013 21:17
To: ANT_THOMAS 2 of 6
((1023 - rawvalue) / 1023) * 100
From: ANT_THOMAS21 Nov 2013 21:42
To: Chris Cooper (DEATHTERRAPIN) 3 of 6
It was simple! Thanks Chris.
From: Chris Cooper (DEATHTERRAPIN)21 Nov 2013 21:53
To: ANT_THOMAS 4 of 6
No problem!
From: Peter (BOUGHTONP)21 Nov 2013 22:53
To: ANT_THOMAS 5 of 6
Or just: 100 - (rawvalue/10.23)
From: ANT_THOMAS21 Nov 2013 22:58
To: Peter (BOUGHTONP) 6 of 6
Or that way :)