Web Applet Not Loading
in
Programming Questions
•
3 years ago
For some reason when I export my processing sketch, the applet will not start after I open index.html. The area that should be my sketch is only white. Also, I have tried exporting other sketches and they work fine.
Here's my code:
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
color off = color(4, 79, 111);
color on = color(84, 145, 158);
int maxval, val;
void setup() {
size(470, 280);
arduino = new Arduino(this, "COM3", 9600);
arduino.pinMode(0, Arduino.INPUT);
}
void draw() {
val = arduino.analogRead(0);
if(val >= maxval)
maxval = val;
background(off);
//graphical representation of motion
rect(20, 60, 50, arduino.analogRead(0));
rect(260, 60, 50, maxval);
//values as text and output lables
stroke(255);
noFill();
rect(80, 60, 75, 20);
rect(170, 60, 75, 20);
text("WIND SPEED CALCULATOR", 140, 10, 500, 500); //title
text("Current Value", 80, 55);
delay(130);
text(arduino.analogRead(0), 115, 75);
text("Max Value", 180, 55);
text(maxval, 200, 75);
//values to text file
println(arduino.analogRead(0));
int d = day(), m = month(), y = year(), s = second(), mi = minute(), h = hour();
String ms = String.valueOf(m);
String ys = String.valueOf(y);
String ds = String.valueOf(d);
String mis = String.valueOf(mi);
String ss = String.valueOf(s);
String hs = String.valueOf(h);
String date = ms + "/" + ds + "/" + ys + " " + hs + ":" + mis + ":" + ss;
String[] prevfile = loadStrings("C:/AppServ/www/lines.html");
String prev = prevfile[0];
String maxstring = str(maxval);
String valstring = str(val);
//String[] maxvalueoutput = {prev, maxstring, " ", valstring};
String[] currentvalueop = {valstring};
String[] maxvalueoutput = {maxstring};
String[] updated = {date};
//save to file
saveStrings("C:/AppServ/www/windcalc/current.txt", currentvalueop);
saveStrings("C:/AppServ/www/windcalc/max.txt", maxvalueoutput);
saveStrings("C:/AppServ/www/windcalc/date.txt", updated);
}
Here's my code:
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
color off = color(4, 79, 111);
color on = color(84, 145, 158);
int maxval, val;
void setup() {
size(470, 280);
arduino = new Arduino(this, "COM3", 9600);
arduino.pinMode(0, Arduino.INPUT);
}
void draw() {
val = arduino.analogRead(0);
if(val >= maxval)
maxval = val;
background(off);
//graphical representation of motion
rect(20, 60, 50, arduino.analogRead(0));
rect(260, 60, 50, maxval);
//values as text and output lables
stroke(255);
noFill();
rect(80, 60, 75, 20);
rect(170, 60, 75, 20);
text("WIND SPEED CALCULATOR", 140, 10, 500, 500); //title
text("Current Value", 80, 55);
delay(130);
text(arduino.analogRead(0), 115, 75);
text("Max Value", 180, 55);
text(maxval, 200, 75);
//values to text file
println(arduino.analogRead(0));
int d = day(), m = month(), y = year(), s = second(), mi = minute(), h = hour();
String ms = String.valueOf(m);
String ys = String.valueOf(y);
String ds = String.valueOf(d);
String mis = String.valueOf(mi);
String ss = String.valueOf(s);
String hs = String.valueOf(h);
String date = ms + "/" + ds + "/" + ys + " " + hs + ":" + mis + ":" + ss;
String[] prevfile = loadStrings("C:/AppServ/www/lines.html");
String prev = prevfile[0];
String maxstring = str(maxval);
String valstring = str(val);
//String[] maxvalueoutput = {prev, maxstring, " ", valstring};
String[] currentvalueop = {valstring};
String[] maxvalueoutput = {maxstring};
String[] updated = {date};
//save to file
saveStrings("C:/AppServ/www/windcalc/current.txt", currentvalueop);
saveStrings("C:/AppServ/www/windcalc/max.txt", maxvalueoutput);
saveStrings("C:/AppServ/www/windcalc/date.txt", updated);
}
1
