Standard Fruit

Submitted by deb on Wed, 02/27/2013 - 15:15


The is a mock decision support tool to standardize fruit evaluation in different types of environments. The idea is to help human farmers make more confident judgments about fruit ripeness in multiple environments.

The serial will print out what type of fruit you're evaluating based on your pot setting. Processing will also produce an appropriately colored circle for your fruit type. Green for grapes, yellow for bananas, orange if you’re evaluating a citrus fruit.

Evaluating the ripeness of the fruit requires a particular level of light so, if light sensor measures the light as too low for the farmer to visually evaluate the fruit for ripe (or overripe) colors/patterns, Processing will produce a red circle.

Once fruit settings have been confirmed with serial print out and color, and the light level is good enough to make a confident judgment about the fruits visual condition, the user's objective is then to produce a circle of a particular size without breaking the skin of the fruit. There is a natural desire to not break the skin of the fruit so, if you're not able to yield a certain pressure within that innate user parameter, your fruit is too mushy and you get a neon pink circle indicating that your fruit is bad.

This takes advantage of natural instinct while using tech to apply metrics to an otherwise no precise process. A more realistic version of this tool might take the form of a pressure sensor embedded in the blade of a knife and the light sensor somewhere on a non-gripped area of the knife's handle. 

Please note that the Processing code for this project only partially works. I hope to return to this project to correct the glitches with the FSR and complete the necessary conditionals (currently outlined in pseudo code). Elliot was a great resource for helping me understand Processing Code.


Arduino Code:

// Analog pin settings
int aIn = 0;    // Potentiometers connected to analog pins 0, 1, and 2
int bIn = 1;    //   (Connect power to 5V and ground to analog ground)
int cIn = 2;  

// Digital pin settings
int aOut = 9;   // LEDs connected to digital pins 9, 10 and 11
int bOut = 10;  //   
int cOut = 11;  

// Values
int aVal = 0;   // Variables to store the input from the potentiometers
int bVal = 0;  
int cVal = 0;  
int PRINT = 1;
void setup()
  pinMode(aOut, OUTPUT);   // Sets the digital pins as output
  pinMode(bOut, OUTPUT);   
  pinMode(cOut, OUTPUT);
  Serial.begin(9600);     // Open serial communication for reporting

void loop()
  aVal = analogRead(aIn) / 4;  // Read input pins, convert to 0-255 scale
  bVal = analogRead(bIn) / 4;  //
  cVal = analogRead(cIn) / 4;  

  analogWrite(aOut, aVal);    // Send new values to LEDs
  analogWrite(bOut, bVal);
  analogWrite(cOut, cVal);
  if (PRINT){                 // Continuous prints sensor values to guide users
        Serial.print(bVal);   // 100-255 = Citrus  // 50-100 = Banana // 0-50 = Grape or Berry
        PRINT = 1;
        if (bVal < 50 && bVal < 51){
  if (bVal < 100 && bVal > 51){
  if (bVal < 255 && bVal > 100){



Processing Code:

<<< This only partially works >>>

import processing.serial.*;
// Change this to the portname your Arduino board
String portname = "/dev/tty.usbmodem1421"; // or "COM5"
Serial port;
String buf="";
int val = 0;

void setup() {
  port = new Serial(this, portname, 9600);
void draw() {
  if(val > 24) {
    int x = int(random(0,width));
    int y = int(random(0,height));
    drawball(x,y, 10);
void keyPressed() {
  if(key == ' ') {
    background(40,40,40);  // erase screen
  else {
    int x = int(random(0,width));
    int y = int(random(0,height));
    drawball(x,y, 10);
// draw balls
void drawball(int x, int y, int r) {
  for (int i=0; i<100; i++ ) {


void serialEvent (Serial port) {
String myString = port.readStringUntil('\n');  //read serial until new line
  if (myString != null) {
    println (myString);
    String[] list = (split(myString, ':'));
    println (list);
    int fsr = int(list[3]); // need to convert from string to int
    int pot = int(list[2]);
    int light = int(list[1]);
    println (pot);
    drawball(200,200,pot);  // always draw ball in the same spot
    // radius currently controlled by pot


// radius would be controlled by fsr but there is still a glitch in converting it from string to int
    // fill color controlled by pot value (this would need to be new constructor passed into drawball) colors would be as follows:
       // if pot betwen 0-50 green for grape
       //if pot between 50-100 yellow banana
       //if pot value between 100-255 orange for citrus
       // if light < 100 red for too dark
       // if fsr < 50 pink for mushy fruit
    background(40,40,40);  // erase screen

Your rating: None
Drupal theme by Kiwi Themes.