Ambient Light Sensor as Imput Device

The ambient light sensor of many Apple notebooks is a really nice analog input device. Under normal lighting you get almost a distance reading of you hand over you left ( and/or right) speaker.

I have just posted some code that reads out this sensor (props to Amit Singh) and maps to the translucency of a “opengl brush stroke”.

happy hacking,

I just noticed that I use a function for range mapping in this code. It is not officially part of OF yet (hint!). Here it is:

float ofRangemap(float r1min, float r1max, float r2min, float r2max, float r1val) {  
  *                     r1val  
  *    |- - - - -|--------x----|  
  *    0       r1min       \  r1max  
  *                         \  
  *    |- - - - - -|---------x-------|  
  *    0         r2min      return  r2max  
  r1val = CLAMP(r1val, r1min, r1max);  
  return (r1val - r1min) * ((r2max - r2min)/(r1max - r1min)) + r2min;  

The link is broken – any way you could repost?