const int GSR=A0;
int threshold=0;
int sensorValue;
void setup(){
long sum=0;
Serial.begin(9600);
delay(1000);
for(int i=0;i<500;i++)
{
sensorValue=analogRead(GSR);
sum += sensorValue;
delay(5);
}
threshold = sum/500;
Serial.print("threshold =");
Serial.println(threshold);
}
void loop(){
int temp;
sensorValue=analogRead(GSR);
Serial.print("sensorValue=");
Serial.println(sensorValue);
temp = threshold - sensorValue;
}
-
In what way are you attempting to "plot" it? I see data arriving on serial fine.– MajenkoCommented Mar 25, 2016 at 13:09
-
1"serial plotter" command– Gabriele GiordanoCommented Mar 25, 2016 at 13:34
-
Maybe you should get rid of the "sensorValue=" cruft and just prinln() the value? I have never used that plotter so not sure how it handles the data, but from what I have read it just wants raw numbers.– MajenkoCommented Mar 25, 2016 at 13:37
-
what does cruft mean?– Gabriele GiordanoCommented Mar 25, 2016 at 13:40
-
"badly designed, unnecessarily complicated, or unwanted code or software."– MajenkoCommented Mar 25, 2016 at 13:41
|
Show 6 more comments
1 Answer
The serial plotter requires just numbers and nothing else.
It can't understand the data in the format:
sensorValue=49
It just expects:
49
Remove the line
Serial.print("sensorValue=");
and it will start working.
-
I didn't understand how much readings it takes in a second. It's 1000milliseconds/ delay (=5) = 200? Commented Mar 25, 2016 at 15:53
-
It takes as many readings as it can. You have no timing specified, so the number of samples will be defined by the speed of the serial data, and the quantity of the serial data. The quantity of the serial data depends on the values being sampled.– MajenkoCommented Mar 25, 2016 at 15:54
-
-
Either with
delay()
(crude),millis()
(pretty good) or a timer (most accurate).– MajenkoCommented Mar 25, 2016 at 18:44 -
I don't understand how to use the timer. Which kind of argument does it accept? Commented Mar 25, 2016 at 18:57