I am receiving data from an LDR which I am inputting into processing. The data seems to be received to Arduino correctly however when I try to constrain and map the values into data processing can compute it prints a series of values with letters in front rather than values between the range I have specified. Any help identifying where I have gone wrong would be so so helpful!
ARDUINO CODE
int rval=0;
int lightval;
//Recorded minimum and maximum values
int minval=0;
int maxval=950;
void setup()
{
Serial.begin(9600);
}
void loop()
{
rval = analogRead(1);
Serial.println(rval);
rval=constrain(rval,minval,maxval); //constrain the value rval between 0 and 950.
lightval=map(rval,minval,maxval,0,255); //converts the range of rval. Mapped from 0-950 to 0-255. now stored as lightval.
Serial.println(lightval);
Serial.write(lightval);
}
