The device is currently powered through USB.
Here is the Arduino code:
int hitcount = 0;
int ledPin = 13;
int piezo = 9;
int message;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(piezo, OUTPUT);
Serial.begin(9600);
}
void loop() {
delay(1000);
//digitalWrite(ledPin, HIGH);
//delay(30);
//digitalWrite(ledPin, LOW);
int message = Serial.read();
if(message > hitcount){
hitcount = message;
digitalWrite(ledPin, HIGH);
digitalWrite(piezo,HIGH);
delay(200);
digitalWrite(piezo,LOW);
delay(4800);
digitalWrite(ledPin, LOW);
}
}
And here is the Processing code:
import java.net.*;
import processing.serial.*;
Serial theSerial;
void setup() {
theSerial = new Serial(this, Serial.list()[1], 9600);
}
void draw() {
delay(10000);
try {
URL theURL = new URL("http://coderedsupport.com/test/visitors/livecount.txt");
InputStream theInputStream = theURL.openStream();
InputStreamReader theInputStreamReader = new InputStreamReader(theInputStream);
BufferedReader theBufferedReader = new BufferedReader(theInputStreamReader);
String theString = theBufferedReader.readLine();
theSerial.write(theString);
println(theString);
}
catch (Exception theException) {
theException.printStackTrace();
}
}
--The processing code checks the text file and sends the value through the Serial port. The Arduino reads the value to see if it is higher than the previous transmission.
Thanks for any help...
PS: If there are any parts of this code that can be cleaned up for efficiency, I am open to criticism. ![]()