CodingCalculations

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  ANT_THOMAS  
 To:  ALL
40799.1 
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.


0/0
 Reply   Quote More 

 From:  Chris Cooper (DEATHTERRAPIN)  
 To:  ANT_THOMAS     
40799.2 In reply to 40799.1 
((1023 - rawvalue) / 1023) * 100
+1/1
 Reply   Quote More 

 From:  ANT_THOMAS  
 To:  Chris Cooper (DEATHTERRAPIN)     
40799.3 In reply to 40799.2 
It was simple! Thanks Chris.
0/0
 Reply   Quote More 

 From:  Chris Cooper (DEATHTERRAPIN)  
 To:  ANT_THOMAS     
40799.4 In reply to 40799.3 
No problem!
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS     
40799.5 In reply to 40799.1 
Or just: 100 - (rawvalue/10.23)
+1/1
 Reply   Quote More 

 From:  ANT_THOMAS  
 To:  Peter (BOUGHTONP)     
40799.6 In reply to 40799.5 
Or that way :)
0/0
 Reply   Quote More 

Reply to All    
 

1–6

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats