using Buzzer with Processing

Nikolaus Gradwohl2009-09-06T18:34:00+00:00

I have written a processing sketch that shows how to use the buzzer for the ps2. the sketch uses the proCONTROLL library and draws a rectangle for every button on the buzzer.

buzzer test

JInput uses a native component for every os, therefor i didn't export it as an applet

import procontroll.*;
import java.io.*;

ControllIO controll;
ControllDevice buzz;

int[] pos = { 
  0, 4, 3, 2, 1,
  5, 9, 8, 7, 6, 
  10, 14, 13, 12, 11, 
  15, 19, 18, 17, 16 };  

int[] col = { 
  color( 255, 0, 0 ), 
  color( 255, 255, 0 ), 
  color( 0, 255, 0 ), 
  color( 255, 128, 0 ), 
  color( 0, 0, 255 ) 
};

void setup(){
  size(400,400);
  controll = ControllIO.getInstance(this);
  buzz = controll.getDevice( "Namtai Buzz" );

}

void draw() {
  background( 0 );
  for ( int i = 0; i < 20; i++) {

    ControllButton b = buzz.getButton( i );
    if (b.pressed()) {
      fill( col[ i % 5 ] );
    } else {
      fill( 128 );
    }
    rect( int( pos[i] / 5 ) * width /4  , (pos[i] % 5) * height / 5, width/4, height/5);
  }
}
Tweet This! submit to reddit Digg! Tags: | no comments | no trackbacks

See also:

sketch experiment 7 - osc events
nested cubes in processing
processing phaseflower
Time Perception
de jong attractor

Trackbacks

Comments

Leave a response

Leave a comment