Introduction: Paper Tosket

Our DIY project, named ‘Paper Tosket’.

What is it made for? It supports people to use the trashcan more (less garbage in public space). It applies a ‘fun aspect’ throwing your garbage in de trashcan. It’s the principle of a basket match where you get a point for throwing something into the basketball net.

We started with programming in Processing and Arduino, based on an ultrasonic distance sensor >> http://www.parallax.com/tabid/768/ProductID/92/Default.aspx. This sensor measures distance and is perfect for any number of applications that require you to perform measurements between moving or stationary objects.

When someone throws a ball of paper into the Paper Tosket, the distance which is measured by the Ultrasonic Distance Sensor reduces and therefore the numbers which arduino is gaining reduce too. We use this degradation in our code for increasing the current score with one point. These points increase every time a ball of paper is thrown in. When the current score is 99, the counter resets and it restarts counting from 0 points.

Additional, we add some sounds. There is a sound playing when someone throws in the paper tosket and gets a point, and there's another sound playing when you are the de 99th person who scores. We also milled a frame for our screen and a basketball net. The name above our screen is made by a laser cutter. 

For connecting the sensor to arduino have a look at these website >> http://www.robot-electronics.co.uk/htm/arduino_examples.htm. Search for ‘SRF02’.

We also made a video about our project, nevertheless a part of it is in dutch, it can still be interesting to watch >> https://vimeo.com/52013372.




Below the code we used for our Paper Tosket in processing and Arduino.

CODE FOR PROCESSING
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import processing.serial.*;

Serial myPort;
PImage bg;
AudioPlayer player;
AudioPlayer player2;
Minim minim;

int currentScore;
int scoreIncrease;
int endScore;
int inByte;

void setup(){
size (800, 600);
println(Serial.list());
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);
bg = loadImage("achtergrond.JPG");

minim = new Minim(this);
player = minim.loadFile("Punt.mp3");
player2 = minim.loadFile("Winnaar.mp3");

currentScore = 0;
scoreIncrease = 1;
endScore = 99;
}

void draw(){
background(bg);
text(currentScore,400,545);
fill(0);
textSize(290);
}
void serialEvent(Serial myPort){
int inByte = myPort.read();
println(inByte);

if(inByte < 60){
currentScore += scoreIncrease; //increase currentScore
println(currentScore);
player.rewind();
player.play();

if(currentScore == endScore){
player2.play();
currentScore = 0;
}
}
}

CODE FOR ARDUINO
#include

void setup(){
Wire.begin();
Serial.begin(9600);
}

int reading = 0;

void loop(){
int data = 0;
int newAddress = 0x70;
boolean hold = false;

while(1) {
data = readData(newAddress);
if(data!=0) {
Serial.write(data);
if(data < 50 && hold==false) {
//Serial.write = 1;
hold = true;
}
else if(data > 200 && hold==true) {
hold = false;
}
}
else {
Serial.println("0");
}
delay(90);
}
}
void changeAddress(int oldAddress, int newAddress)
{
Wire.beginTransmission(oldAddress);
Wire.write(byte(0x00));
Wire.write(byte(0xA0));
Wire.endTransmission();
Wire.beginTransmission(oldAddress);
Wire.write(byte(0x00));
Wire.write(byte(0xAA));
Wire.endTransmission();
Wire.beginTransmission(oldAddress);
Wire.write(byte(0x00));
Wire.write(byte(0xA5));
Wire.endTransmission();
Wire.beginTransmission(oldAddress);
Wire.write(byte(0x00));
Wire.write(newAddress);
Wire.endTransmission();
}

int readData(int address) {
int reading = 0;

Wire.beginTransmission(address);

Wire.write(byte(0x00));
Wire.write(byte(0x51));
Wire.endTransmission();
delay(70);
Wire.beginTransmission(address);
Wire.write(byte(0x02));
Wire.endTransmission();

Wire.requestFrom(address, 2);
if(2 <= Wire.available())
{
reading = Wire.read();
reading = reading << 8;
reading |= Wire.read();
return reading;
}
return 0;
}