Why is the serial plotter showing just a line?

Now my serial plotter is just showing this...

What am I missing?

code:

byte myValue = A0;
unsigned long LoopTimer = 0;
const int LoopTime = 50;


void setup() 
{
    //A0 input (default)
    Serial.begin(57600);
    
}

void loop() 
{

 
 if (millis() >= LoopTimer){
 LoopTimer += LoopTime;
 myValue += 8;

 Serial.println(myValue);

 }
    
}//loop

Looks fine to me.
What did you expect?

I'm trying to show an ECG signal so it has to look like the heart beats..

But the function you gave it is a sawtooth, not an ECG.

your myValue is a byte
you have initalized it with A0, which might be nothing else than 14.
you add 8.
you do that over and over again.
after some time (255) it rolls over to 0
so what.

Did you miss an analogRead?

1 Like

How can I convert it to an ECG? I'm confused...

Is there a analog signal at pin A0 ?
Can you tell more about that signal ?

Use an array of ECG values, and write those to the serial plotter.

Yes, my input from my ECG is an analog signal that goes to A0. I'll attach the picture of the oscciloscope.

I think so, I just don't know where to put it

To get the data of an analog input, Arduino has the function analogRead(): analogRead() - Arduino Reference
There is often a very small example or links to examples.

You misunderstand this statement completely. My guess, you think it "connects" the value with the data coming into the port. It's much more limited than that. It actually just creates a new variable and gives it the initial value of the pin number of the port, not the data.

You should make it a const, and give it an appropriate name if you want to do it:
const byte analogPin = A0;
then you can use
int analogValue = analogRead(analogPin);
instead of
int analogValue = analogRead(A0);

1 Like

I tried this, but now it's just a straight up line, it's not even going down..

  • show your updated code
  • show your schematic what you have connected to what
  • show real pictures of your setup where we can see each any every wire and module
  • link to the datasheet of your sensor.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.