Hi all,
Recently I'm facing a problem in my project. It was working great for 2 weeks but now it doesn't work properly.
My circuit is very basic, I read data from photocell in my arduino, and if the value is below a number, lets say 200, I send 0,BYTE from serial port.
Code is like this;
Code:int photocellPin = 0;
int photocellReading;
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
photocellReading = analogRead(photocellPin);
if (photocellReading<=200) {
Serial.print(0, BYTE);
}
else {
Serial.print(1, BYTE);
}
}
When I check serial monitor, It works great. But when I read this data from serial in Processing it messes up. It always shows 1, when i print the value I get from serial port.
Processing code is like this; (again very simple)
Code:import processing.serial.*;
Serial myPort;
int ardgelen;
void setup()
{
size(200, 400);
String portName = "COM3";
myPort = new Serial(this, portName, 9600);
}
void draw() {
if(myPort.available()>0) {
ardgelen = myPort.read();
println(ardgelen);
}
}
I was able to get the correct numbes in Processing for two weeks, and very oddly it works well in another computer. But now It decided to not work properly.
What is the thing am i missing?