Announcements

November 24, 2007
Reading for November 27th, are now posted. Enjoy!

October 2, 2007
To upload your thoughtless acts, create a new assignment page like any other lab. You'll see "Thoughtless Acts" listed as one of the assignment options.

May 24, 2008
This site has been archived and is no longer editable. Stay tuned for the next version, coming in the fall!


Processing - Random Ball

Project Members: 
Jill Blue Lin

Description

Draws balls randomly on the screen. I made some small modifications to the existing code. (Sorry, that's all ...)

Programming Part 

/*
 * Arduino Ball Paint
 * (Arduino Ball, modified)
 * ----------------------
 *
 * Draw balls randomly on the screen, size controlled by a device
 * on a serial port.  Press space bar to clear screen, or any
 * other key to generate fixed-size random balls.
 *
 * Receives an ASCII number over the serial port,
 * terminated with a carriage return (ascii 13) then newline (10).
 *
 * This matches what Arduino's " Serial.println(val)" function
 * puts out.
 *
 * Created 25 October 2006
 * copyleft 2006 Tod E. Kurt <tod@todbot.com
 * http://todbot.com/
 */
import processing.serial.*;
// Change this to the portname your Arduino board
String portname = "/dev/tty.usbserial-A4001nMC"; // or "COM5"
Serial port;
String buf="";
int cr = 13;  // ASCII return   == 13
int lf = 10;  // ASCII linefeed == 10
void setup() {
  size(300,300);
  frameRate(10);
  smooth();
  background(40,40,40);
  noStroke();
  port = new Serial(this, portname, 9600);
}
void draw() {
}
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++ ) {
    fill(255-i,i,50);
    ellipse(x,y,r,r);
  }

}
// called whenever serial data arrives
void serialEvent(Serial p) {
  int c = port.read();
  if (c != lf && c != cr) {
    buf += char(c);
  }
  if (c == lf) {
    int val = int(buf)/2;
    println("val="+val);
    int x = int(random(0,width));
    int y = int(random(0,height));
    drawball(x,y,val);
    buf = "";
    //background(40,40,40);  // erase screen
  }
}

Mechanical Part

I frequently don't know when to water my orchid. My sister, who is an avid orchid collector, suggested that I use the orchid's weight as an indicator. If it is too light, it's time to water the plant. I have a hard time with this because I am not sensitive enough to the differences in weight when the plant is recently watered, slightly dry, too dry, etc.

My idea is to place an FSR under a potted orchid plant. If the plant is freshly watered (heavy), the green LED would be at its maximum brightness. If the plant is too dry, the red LED would be at its maximum brightness.

Potted Orchid

Potted Orchid


Comments

don't be sorry about the

don't be sorry about the minor code change! You more than made up for it in the mechanical portion of the assignment! what a great idea. I often times here that orchids have evolved to die. Perhaps this will help change that a bit!


Powered by Drupal - Design by Artinet