ria_nikki_pam
YaBB Newbies
Offline
Posts: 6
loadImage issue: doesn't display the 2nd image
Apr 20th , 2007, 4:48am
Hi, we're completely lost with Processing (and Arduino). Basically we're using a heat sensor and depending on what range the temperature is in, it'll show a different image. Our problem is that it'll only show the first image based on the first reading, and even if the temperature changes to fit into the other range, the image will remain the same. We want the image to change each time it switches ranges. We're new to this and we've searched the Reference and looked up similar codes and we're STILL lost. If someone could help us, that would be great! Here's our code: import processing.serial.*; String portName= "/dev/tty.usbserial-A3000YM6"; //declare the name of the port Serial port; PImage a; PImage b; int reading = 0; void setup() { size(100, 100); PImage a; a = loadImage("helmet_green.jpg"); image(a, 0, 0); PImage b; b = loadImage("helmet2.jpg"); image(b, 0, 0); println("Available serial ports:"); println(Serial.list()); // Uses the first available port port = new Serial(this, portName, 9600); } void draw() { int reading = 0; while (port.available() > 0) { reading = port.read(); if(reading < 62) { b = loadImage("helmet2.jpg"); image(b, 0, 0); println("Show image 1"); delay(1000); } else if(reading >= 62) { a = loadImage("helmet_green.jpg"); image(a, 0, 0); println("Show image 2"); delay(1000); } println(reading); reading = 0; } } Thanks in advance for any help you can offer us!