Introduction: FOOF FOR FISH EXPERIMENT

"Food for Fish Experiment",
a network activacted food dispenser for an aquarium located in Venice.
I made it using Processing .net library, Arduino and a servo motor.

Food for fish experiment is a web page that shows a 24/24 live streaming video of a fish in an aquarium. Thanks to an automatic device which can be activated remotely, you can feed the fish by clicking the FOOD-button placed just below the video box. An interface that starts a connection between the real and the virtual side, in order to create a series of relationships between the user logged on the net and a fish in an aquarium. It conveys a flow of information towards a static point in the world, simulating the coercion of information systems. It functions as an electronic and mechanical device operated by remote, transforming information into food for the fish which, being inserted into the particular time of the internet, becomes a victim of the network overload. Food For Fish basically is a work in progress, an experiment that takes advantage of the variability and misunderstanding which are typical of the network, and is not intended to have a defined resolution, but to sample the attitudes of the average user in relation with the non-places of the internet.

Step 1: Applet

// K_FISH_ARDUINO code:
// Read data from the serial and open/close the food-dispenser
  #include <Servo.h>
char val; // Data received from the serial port
int ledPin = 13; // Set the pin to digital I/O 13


Servo myservo;  // create servo object to control a servo
int pos = 0;    // variable to store the servo position

void setup() {
pinMode(ledPin, OUTPUT); // Set pin as OUTPUT
Serial.begin(9600); // Start serial communication at 9600 bps
myservo.attach(9);  // attaches the servo on pin 9 to the servo object
myservo.write(0);
}

void loop() {
if (Serial.available()) { // If data is available to read,
val = Serial.read(); // read it and store it in val
}
if (val == 'H') { // If H was received:
  digitalWrite(ledPin, HIGH); // turn the LED on
    for(pos = 0; pos < 360; pos += 1)  // and OPEN: goes from 0 degrees to 180 degrees
  {                                  // in steps of 10 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    //delay(2);                       // waits x ms for the servo to reach the OPEN position
  }

  for(pos = 360; pos>=1; pos-= 1)     // CLOSE: goes from 180 degrees to 0 degrees
  {                               
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    //delay(2);                       // waits X ms for the servo to reach the CLOSED position
   
  }
 

} else {
digitalWrite(ledPin, LOW); // Otherwise turn it OFF
}
//delay(5); // Wait 10 milliseconds for next reading
}


---------------------------------------------------------------------------------------
/*

FISHSERVER: START FIRST AND WAIT TILL IT'S WORKING

FUNCTIONS:
READS FROM NETWORK
AND WRITES TO SERIAL

written by KK for Cerbero

*/

import processing.net.*;
import processing.serial.*;

Server fishS;  // Create object from Server class
Client fishC;    // Create object from Client class
Serial myPort;  // Create object from Serial class

int c;          // Data received from the network port
int network_port = 1863;
int serial_baud_rate = 9600;

// Whether or not to print data coming from the serial port in Processing.
//boolean print_in_processing = true;

void setup()
{
    fishS = new Server(this, network_port);
    
  String portName = Serial.list()[1];
  println(Serial.list());  // Print the available serial ports.
  myPort = new Serial(this, portName, 9600);   }
   
void draw()
{

  Client fishC = fishS.available();

  if (fishC != null) {
    if (fishC.available() > 0) {
    c = fishC.read();
    if (c == 1) {   // if received number is 1
myPort.write('H');   // send an H to start motor
}        
else                            // else
{ myPort.write('L');  }         // send an L
//if (print_in_processing) println(c);//((char) c);
        }
        // }
    }
}


void serverEvent(Server someServer, Client someClient) {
  println("New client: " + someClient.ip());
  // ServerEvent message is generated when a new client connects to an existing server.
}

---------------------------------------------------------------------------------------------

/*

FISHCLIENT: START ONLY AFTER SERVER IS UP AND GOING!!!

FUNCTIONS:
READS FROM BUTTON
AND WRITES TO NETWORK

written by KK for Cerbero

*/

import processing.net.*;
Server fishS; 
Client fishC; 

PImage foodKey;
PImage foodKey2;

void setup() {
 
size(125, 50);

foodKey= loadImage("foodKey.png");
foodKey2= loadImage("foodKey2.png");

// println("Initializing network connection to FishServer...");
fishC = new Client(this, "faustofalchi.blogdns.org", 1863);
// println("... connection to server succesfull!");

}

void draw() {
 
   image(foodKey,0,0);                    // show button_idle image
  
  if (mouseOverRect() && mousePressed) {  // If button is activated
   image(foodKey2,0,0);        // show button_active image
   fishC.write(1);            // WRITE TO NETWORK - send an H to indicate mouse is over square
  }              

    else {fishC.write(0); }       // If button is not pressed,
                                 //  WRITE TO NETWORK - send an L
}

boolean mouseOverRect() { // Test if mouse is over square
  return ((mouseX >= 0) && (mouseX <= 124) && (mouseY >= 0) && (mouseY <= 50));
}