Interface and Application programming

For this week I decided to work on my application in Java. My plan is to create a circle that grows bigger when the sensor has a bigger value. Finally when the value gets high enough the circle will grow a smiley face. So far I have been working on learning Java using DR. Java. Also I have been using video tutorials from http://www.javavideotutes.com/lessons. I highly recommend them for anyone who wants to learn Java. However in order to read data from the serial port I needed to use an extension. Javax.comm. Once I finally managed to get the extension into the library area I started to try and use it. However I ran out of time and have yet to finish my program. When I came back later I discovered the problem. Javax.comm is for Windows not Mac OS X. I found another extension RX/TX which does the same thing. However I did not know how to use it and still have not figured it out. Since then I decided to program the application in Processing because it is simpler to learn in a limited amount of time. After figuring out how to read serial data and create shapes I managed to write a program that changes the color of a circle depending on the value of the sensor.

import processing.serial.*;

Serial serialPort;
int col = 0;
int umm = 0;
void setup() {
 size(500, 500);
 background(51);
 noStroke();
 smooth();
 println(Serial.list());
 serialPort = new Serial(this, Serial.list()[0], 9600);

}

void draw() 
{
  color ahh = color(255, 0, 0);
  color yay = color(0, 255, 0);
  ellipseMode (CENTER);
  ellipse(250, 250, 100, 100 );
  while (serialPort.available() > 0) 
   {
    umm = serialPort.read();
   }
   if (umm >10); 
   {
   println(umm);
     if (umm > 225) 
     {

        fill(ahh);
      }
     else if(umm >6)
     {
       fill(yay);
     }
   }
}

When the value was lower than a set amount, which will be changed depending on background light the circle is green because that means it is bright enough to see. When the value is greater than the set amount the circle will be red.

A video of it working.


Next