electronicghost
YaBB Newbies
Offline
Posts: 3
Help with crashing applet
Mar 13th , 2008, 7:12am
Hello, I have a processing program that reads a text file for a single line with an integer and it is crashing/stops communicating over serial after a while. It runs for a good 5 - 10 min and then stops sending serial data. The text file is being written to by another processing app, that merely increases the number in the text file each time the counter program is run. That works fine. The problem lies with the following program. // RileyHarmon.com // University of Oklahoma School of Art import processing.serial.*; Serial port; int lastCount = 0; void setup() { size(100,100); frameRate(12); println(Serial.list()); port = new Serial(this, Serial.list()[3], 9600); } void draw() { String lines[] = loadStrings("output.txt"); int kills = int(lines[0]); if (kills > lastCount) { port.write('H'); lastCount = kills; } else { port.write('L'); } } It is sending the serial commands to an arduino and is only doing that. The arduino is just receiving those commands and doing a simple digitalWrite. Any ideas as to why the app above stops talking to the ardunio. Here is the arduino code below, even though I think the problem is with the code above. //RileyHarmon.com //University of Oklahoma School of Art char val; // Data received from the serial port int ledPin = 13; // Set the pin to digital I/O 4 int dripPin = 7; void setup() { pinMode(ledPin, OUTPUT); // Set pin as OUTPUT pinMode(dripPin, OUTPUT); Serial.begin(9600); // Start serial communication at 9600 bps } void loop() { if (Serial.available()) { // If data is available to read, val = Serial.read(); // read it and store it in val } if (val == 'H') { // If H was received digitalWrite(ledPin, HIGH); digitalWrite(dripPin, HIGH); delay(1000); digitalWrite(ledPin, LOW); digitalWrite(dripPin, LOW); delay(1000); } else { digitalWrite(ledPin, LOW); digitalWrite(dripPin, LOW); } } Any ideas? Need help soon as this is class project due soon. Thanks!