0
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;
  }
11
  • In what way are you attempting to "plot" it? I see data arriving on serial fine.
    – Majenko
    Mar 25, 2016 at 13:09
  • 1
    "serial plotter" command 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.
    – Majenko
    Mar 25, 2016 at 13:37
  • what does cruft mean? Mar 25, 2016 at 13:40
  • "badly designed, unnecessarily complicated, or unwanted code or software."
    – Majenko
    Mar 25, 2016 at 13:41

1 Answer 1

3

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.

17
  • I didn't understand how much readings it takes in a second. It's 1000milliseconds/ delay (=5) = 200? 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.
    – Majenko
    Mar 25, 2016 at 15:54
  • How can I specify the timing? Mar 25, 2016 at 18:43
  • Either with delay() (crude), millis() (pretty good) or a timer (most accurate).
    – Majenko
    Mar 25, 2016 at 18:44
  • I don't understand how to use the timer. Which kind of argument does it accept? Mar 25, 2016 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.