Examples - Wiring Lib - AnalogIn Async
Wiringlib - Supersonic Async
This example shows the use of an analog input device using WiringLib in Processing. The sensors are called asynchronic, meaning you get the values directly in the return statement of the calling function!
Copy this code to your Processing Sketch
// 31 October 2008 // Infrared // by Christoph Wartmann and Etienne Ribeiro import processing.core.*; import gnu.io.*; import Wiring.*; import processing.serial.*; // Const int analogPin = 0; // Analog pin (where the infrared-sensor is connected) int colDot = color (255, 0, 0); // Color of dot static String comPort = "COM4"; // Var SerialLib objSerialLib; int val = 0; // Setup void setup(){ size(400,400); // Wirng-Object objSerialLib = new Wiring.Async.SerialLib(this, comPort); } // Main-Loop public void draw(){ background (0); // Values form 0 to 1023 val = objSerialLib.returnAnalogInput(analogPin); val = val * 4; // draw dot fill (colDot); smooth(); ellipse (width/2, height/2, width*val/1024, height*val/1024); // take a break delay(10); }