Skip navigation

I’ve been thinking about kiosks a lot lately, and I experimented with a control panel that uses different sized tokens to activate switches.

(I forgot to take a photo…)  I made four pairs of switches using wire stretched over the top of a box.   The switches were in pairs about the size of a quarter, it was possible to read all switches at once using an Arduino, then a byte was sent to Processing for visualization.   If smaller or larger change was used, different numbers of switches could be activated.

arduino code


void setup() {
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(6, INPUT);
  pinMode(7, INPUT);
  pinMode(8, INPUT);
  pinMode(9, INPUT);
  pinMode(10, INPUT);

  Serial.begin(9600);
}

void loop(){
  int i = 0;
  byte b = 0;

  for(i=0; i< 8; i++) {

    if (digitalRead(i+2) == HIGH) {
      b = (b | (1<<i));
      //      Serial.println(i, HEX);
    }
    Serial.println(b, BYTE);
  }
}

&#91;/sourcecode&#93;

processing code (displays a different sized box)

&#91;sourcecode language='java'&#93;

//-*-Java-*-
// exercise 2 -- display, loosely based on
// Graph
// by David A. Mellis
//

import processing.serial.*;

Serial port;
String buff = "";
int NEWLINE = 10;

void setup()
{
    size(500,500);

    println("Available serial ports:");
    println(Serial.list());

  // Uses the first port in this list (number 0).  Change this to
  // select the port corresponding to your Arduino board.  The last
  // parameter (e.g. 9600) is the speed of the communication.  It
  // has to correspond to the value passed to Serial.begin() in your
  // Arduino sketch.
  port = new Serial(this, Serial.list()&#91;0&#93;, 9600);

  // If you know the name of the port used by the Arduino board, you
  // can specify it directly like this.
  //port = new Serial(this, "COM1", 9600);

}

void draw()
{
    int b = 0;
    background(0);
    stroke(255);

    while (port.available() > 0) {
    b = port.read();
    if ((b == 10) || (b == 13) || ( b == 48)) {
        continue;
    }
    else if (b > 0) {
        //        println(b);
        rect(20,20,b*1.5,b*2);
    }
    }
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: