/* Gainer Test Control the LED by mouse, the background color by the button. The circuit: * inputs - Button: the on-board tactile switch * outputs - LED: the on-board LED Created 10 May 2009 By Shigeru Kobayashi Modified 13 May 2009 By Shigeru Kobayashi http://funnel.cc/ http://gainer.cc/ */ import processing.funnel.*; Gainer gainer; color backgroundColor = color(50, 50, 50); void setup() { size(200, 200); textFont(createFont("CourierNewPSMT", 12)); gainer = new Gainer(this, Gainer.MODE1); // NOTE: // Regarding Gainer, a SetPoint filter is attached on each // digital input (including the button) by default. // You can add a SetPoint filter to analog inputs as follows: // gainer.analogInput(0).addFilter(new SetPoint(0.5, 0.1)); } void draw() { background(backgroundColor); for (int i = 0; i < gainer.analogInput.length; i++) { text("a " + i + ": " + gainer.analogInput(i).value, 10, 20 + 20 * i); } } void mousePressed() { gainer.led().value = 1.0; } void mouseReleased() { gainer.led().value = 0.0; } // on change from 0 to 1 (or non-zero) void risingEdge(PinEvent e) { if (e.target.number == Gainer.button) { // the button is pressed backgroundColor = color(255, 50, 50); } } // on change from 1 (or non-zero) to 0 void fallingEdge(PinEvent e) { if (e.target.number == Gainer.button) { // the button is released backgroundColor = color(50, 50, 50); } }