Hi PaulS,
I think it is only a 4 digit integer number that i am sending, Well here is the code,
Arduino:
int ledTX = 12; //Receives InfraRed signal
int photodiodePin = 2; // Photodiode connected to digital pin 2
int lastState;
unsigned long startTime;
unsigned long elapsedTime;
void setup() {
Serial.begin(9600);
pinMode(ledTX, OUTPUT);
pinMode(photodiodePin, INPUT); // sets the digital pin as input to read photodiode
}
void loop() {
byte currentState = digitalRead(photodiodePin);
digitalWrite(ledTX, HIGH); // turn the TX Infrared LED on
if(currentState == LOW && lastState == HIGH){
startTime = millis();
}
if(currentState == HIGH && lastState == LOW){
elapsedTime = millis() - startTime;
Serial.println(elapsedTime);
Serial.write(elapsedTime);
}
lastState = currentState;
}
Processing: the elapsedTime variable has been declared as an integer but I am only getting a print out of 0. There is no change when I put anything in the photogate.
import processing.serial.*;
Serial port;
int elapsedTime;
void setup() {
size(200, 200);
background(204);
noStroke();
port = new Serial(this, 9600);
}
void draw() {
if (0 < port.available()) {
elapsedTime = port.read();
}
println(elapsedTime);
}
Thanks,
Shane