Arduino Oscilloscope problems

I can make an oscilloscope with an Arduino using the serial plotter, and this kind of works. my problem is that it cant read high frequencies. I have an inverter that I want to view the waveform of and I just see a bunch of lines smushed together. How to I make it handle higher frequencies using the serial plotter?

Reducing the ADC resolution can allow a higher sample rate - take a look at the ADC section of the datasheet for your unnamed processor.

I'm using an Arduino Nano, i'm not sure how to do that.

Before we go much further, what sort of signal frequency are you wanting to look at?

I want to view the sine wave of 60Hz for my homemade inverter project. And I also want to see the output of other inverters and generators.

You are limited by how fast you can send text to the Serial Plotter. Use the highest baud rate you can get to work, like 250000, 500000, 1000000, or 2000000 baud. If you have a Leonardo or Micro available, the USB interface may allow faster communication.

To increase the ADC conversion rate, decrease the ADC clock prescale. The selection is made in the ADCSRA (ADC Status Register A). Set bits ADPS2, ADPS1 and ADPS0 to 1,0,0 to get a prescale of 16 (clock at 1 MHz) the fastest the ADC is designed to go.

// Set ADC Prescale to 16
ADCSRA |=  _BV(ADPS2);  // Turn  on ADSP2
ADCSRA &= ~_BV(ADPS1);  // Turn off ADSP1
ADCSRA &= ~_BV(ADPS0);  // Turn off ADSP0

I tried adjusting the baud rate and it did not help. Do I put that piece of code in the setup, or before it?

This sketch gets me about 200 samples per cycle of the background noise which I expect is 60Hz. That's a 12 kHz sample rate. I hope that is good enough for your purposes. I don't think the Arduino UNO can do much better.

void setup()
{
  Serial.begin(2000000);
  delay(200);

  // Set ADC Prescale to 16
  ADCSRA |=  _BV(ADPS2);  // Turn  on ADSP2
  ADCSRA &= ~_BV(ADPS1);  // Turn off ADSP1
  ADCSRA &= ~_BV(ADPS0);  // Turn off ADSP0
}

void loop()
{
  Serial.println(analogRead(A0));
}

For short intervals, you could store samples in memory and output them later.

Ok, thank you for your help. I am using an Arduino Nano if that makes a difference. I'll try this when I get home tonight, ill let you know how it goes.

Using a memory buffer gets a sample rate near 49 kHz.

void loop()
{
  for (size_t i = 0; i < 500; i++)
    buffer[i] = analogRead(A0);
    
  for (size_t i = 0; i < 500; i++)
    Serial.println(buffer[i]);
}

Ok thank you.

I tried these and I still have the same problem, the lines are so dense I cant make out anything.

I just ruined my Nano, so I'm done till I get something else.

You never said what the PWM frequency of your 'sine wave' was. You're going to be out of luck if the PWM frequency is over 5 kHz.

Maybe you should invest in a real oscilloscope.

I was thinking of getting one of those kits you solder that are like $25 because I’m only 13 and can’t afford a real one. That’s why I’m trying to make one.