We’d seen many Arduino projects made using displays to increase the functionality of whatever it is you’re making. We wanted to do the same so opted for a no-frills Oscilloscope! Read on for everything you need to know about this simplified Arduino Nano Oscilloscope. 

Why is an Oscilloscope such an important electronics tool?

The benefits of seeing the characteristics of a signal in terms of amplitude and time are huge. It is for this reason that an Oscilloscope is one of the most popular instruments in any workshop or electronics lab.  

What functionality does this Oscilloscope have?

The Oscilloscope project shown here has been adapted from a design published on the Ardunio Project Hub – see 20KHz Ardunio Oscilloscope using a Nokia 5110 LCD by Mirko Pavleski. I should point out that the design has limited functionality with a timebase from 50mS/div to 0.1mS/div and a top signal input of 5V (without resistor attenuation). That said, it is only based one microcontroller and can be made for little more than the cost of a couple of cups of coffee!

The circuit diagram

A close up of the Oscilloscope screen 

I originally set out to build the project from the Arduino Project Hub but ran into some challenges along the way so I adapted the project to overcome them. The first problem encountered was a corrupted display that was down to not having the Adafruit DotStarMatrix library installed in the Arduino IDE. 

The main change I made was to remove the pullup resistors (10K) from the original design and use the microcontroller’s internal pullups. Also, I have used 4 identical button switches that have push to make contacts. In order to work some very minor changes have been made to the code.

 

Parts Required

  • Ardunio Nano
  • Nokia 5110 LCD (84×48 , 1.6” screen)
  • Button switch (push to make) 4 off
  • Resistor 1K
  • Resistor 4K7

The following libraries need to be installed via the IDE library manager.

  • Adafruit DotStarMatrix
  • Adafruit GFX library
  • Adafruit PCD8544 Nokia 5110 LCD Library

 

The code for oscilloscope

// Oscilloscope project for Nano

#include <Adafruit_GFX.h>

#include <Adafruit_PCD8544.h>

#include <SPI.h>

Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);//CLK,DIN,DC,CE,RST |||| VCC +3.3 V , BL ++ 200 OM ++ 3.3 V

int izm,x,y,u,i2,zz,hold,h0,h1,h2,raz=0,menu,sss=512,u_dig,data[168]{};

unsigned long time,times;

float per;

byte i;

void setup() {Serial.begin(9600);

    display.begin();display.clearDisplay();display.display();

    display.setContrast(40); // contrast setting

    display.setTextSize(1);  // setting font size

    display.setTextColor(BLACK); // setting text color

    pinMode(10,INPUT_PULLUP);  // +

    pinMode(11,INPUT_PULLUP);  // –

    pinMode(12,INPUT_PULLUP);  // hold

    pinMode(8,INPUT_PULLUP);  // sync

    ADMUX  = 0b01000000; // 0B0100000 10 bit A0 // 0B01100000 8 bit A0

    ADCSRA = 0b11110010;// CLK/4;

    analogWrite (9, 127); // PWM 9 OUTPUT

}

void loop() {

///////////////////////////BUTTON CONTROL//////////////////////////////

if(menu==0){

  if(digitalRead(10)==HIGH){if(hold==0){raz++;}if(hold==1){i2=i2+1;}delay(100);}

  if(digitalRead(11)==HIGH){if(hold==0){raz–;}if(hold==1&&hold>0){i2=i2-1;}delay(100);}

  }

  if(digitalRead(12)==LOW){hold++;i2=0;delay(100);}

  if(digitalRead(8)==LOW){menu++;delay(100);}

  if(hold>1){hold=0;}if(menu>1||menu<0){menu=0;}

  if(raz<=0){raz=0;}if(raz>8){raz=8;}

  if(menu==1){hold=0;

  if(digitalRead(10)==HIGH){sss+=24;delay(100);}

  if(digitalRead(11)==HIGH){sss-=24;delay(100);}

  if(sss>1023){sss=1023;}if(sss<0){sss=0;}

  }

   display.setCursor(0,0); // setting cursor position

/////////////////////////SWEEP TIME calibrated by generator ////////////////////////////

  if(raz==0){zz=1;h2=2;per=0.1;}

  if(raz==1){zz=1;h2=1;per=0.2;}

  if(raz==2){zz=12;h2=1;per=0.5;}

  if(raz==3){zz=32;h2=1;per=1;}

  if(raz==4){zz=75;h2=1;per=2;}

  if(raz==5){zz=200;h2=1;per=5;}

  if(raz==6){zz=380;h2=1;per=10;}

  if(raz==7){zz=750;h2=1;per=20;}

  if(raz==8){zz=1900;h2=1;per=50;}

///////////////////////////////////////////////////////////////////

if(hold==0&&millis()-time>0){

 ads();while(izm<sss){ads();h0++;if(h0>5000){break;}}h0=0;// SYNCHRONIZATION

times=micros();

while(i<167){i++;delayMicroseconds(zz);

  ads();data[i]=izm; // MEASUREMENT 10 bit

  }i=0;times=micros()-times;

  Serial.println(times);

}

////////////////////OUTPUT ON DISPLAY///////////////////////////////

  if(millis()-time>100){

    display.clearDisplay();

    if(sss<204&&sss>100){u_dig=10;display.setCursor(0,40);display.print(“0.4V”);}

    else if(sss<100){u_dig=5; display.setCursor(0,40);display.print(“0.2V”);}

    else{u_dig=25;}

     display.setCursor(0,0);

while(i<167){i++;setka();

    display.drawLine(i*h2-i2, 47-data[i]/u_dig,i*h2-i2+h2-1, 47-data[i+1]/u_dig, BLACK);}i=0;

    display.print(per,1);display.print(” mS  “);

  if(menu==0){if(hold==1){display.print(“HOLD   “);}else{display.print(“AUTO   “);}}

  if(menu==1){display.print(sss/200.0,1);display.print(” V “);}

  if(menu==1){display.drawLine(0, 48-sss/u_dig,4, 48-sss/u_dig, BLACK);}

    time=millis();

}

   display.display();    

}// loop

void ads(){ //////// 10 bit ///////////

  do{ADCSRA |= (1 << ADSC);}

  while((ADCSRA & (1 << ADIF)) == 0);izm = (ADCL|ADCH << 8);}

  ////////////////// 8 bit ///////////

  // REQUIRED ALL CHANGEABLE VARIABLES (sss, u_dig)

  // while ((ADCSRA & 0x10)==0);

  //   ADCSRA|=0x10;

  //   izm = ADCH;

void setka(){

for(y=8;y<47;y=y+8){

for(x=0;x<83;x=x+4){

   display.drawPixel(x, y, BLACK);}}

 for(x=0;x<83;x=x+26){

for(y=10;y<47;y=y+4){

   display.drawPixel(x, y, BLACK);}}

}