Processing Ambient Light Sensor Library
September 10th, 2007 • Processing
Based on Amit Singh experiments with the »Ambient Light Sensor« I developed a JNI (Java Native Interface) for reading the sensor values.
This sensor is built-in in every MacBookPro and is intended for adjusting the keyboards and displays brightness depending on the lighting conditions. The sensors are located under both speaker covers.
Download the Processing-Library lmu.zip and unzip it to the “libraries” folder of your Processing installation. The source code is included in the “src” folder.
methods:
// both sensor values in an array public static int[] getLMUArray(); // left sensor value public static int getLMULeft(); // right sensor value public static int getLMURight();
example:
import lmu.*; int lmu_left; int lmu_right; float multi; void setup() { size(800,800); frameRate(20); // initial sensor values int[] lmu_start = LmuTracker.getLMUArray(); lmu_left = lmu_start[0]; lmu_right = lmu_start[1]; multi = 255.0 / (lmu_left); } void draw() { // get current sensor values int[] vals = LmuTracker.getLMUArray(); int li = (int)(vals[0] * multi); int re = (int)(vals[1] * multi); background(255); // left sensor fill(li); rect(0, 0, width/2, height); // right sensor fill(re); rect(width/2, 0, width/2, height); }
Download Processing Library (lmu.zip)
Download Processing Development Environment
Update 03.12.2008
http://blog.formatlos.de/2008/12/03/ambientlightsensor-updated/
3 Responses (Add Your Comment)
-
andrew May 4, 2010at 2:54 pm
hi, i am wondering, is it possible to use webcam as a tool for ambient light sensor aswell?
I am given a school project to use flash and webcam to create a light sensor, could you give me a piece of mind?