Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based Oscilloscope with OLED Display and Adjustable Time/Voltage Scales

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Oscilloscope with OLED Display and Adjustable Time/Voltage Scales

Circuit Documentation

Summary

This circuit is designed around an Arduino UNO microcontroller and includes a 0.96" OLED display for visual output. The circuit also features two pushbuttons with pull-up resistors to provide user input, and a rotary potentiometer to adjust signal input to the Arduino. The Arduino is programmed to read the potentiometer value, adjust settings based on button presses, and display a waveform on the OLED screen.

Component List

Arduino UNO

0.96" OLED

Pushbutton (x2)

Resistor (x2)

Rotary Potentiometer

Wiring Details

Arduino UNO

0.96" OLED

Pushbutton

Resistor

Rotary Potentiometer

Documented Code

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

const int analogPin = A0; // Analog pin for the potentiometer signal
const int sampleSize = 128; // Number of samples
int signalData[sampleSize]; // Array to store signal values

int timeBase = 5;           // Default time base (sampling delay)
int voltageScale = 8;       // Default voltage scale for display height mapping
const int timeBaseButton = 2; // Pin for time base button
const int voltageScaleButton = 3; // Pin for voltage scale button

void setup() {
    pinMode(timeBaseButton, INPUT_PULLUP); // Time base button
    pinMode(voltageScaleButton, INPUT_PULLUP); // Voltage scale button
    Serial.begin(9600);

    if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
        Serial.println(F("SSD1306 allocation failed"));
        for (;;);
    }
    display.clearDisplay();
}

void loop() {
    // Check button states to adjust settings
    if (digitalRead(timeBaseButton) == LOW) {
        timeBase = (timeBase == 10) ? 5 : 10; // Toggle between 5ms and 10ms
        delay(200); // Debounce delay
    }

    if (digitalRead(voltageScaleButton) == LOW) {
        voltageScale = (voltageScale == 16) ? 8 : 16; // Toggle between 8 and 16 for scaling
        delay(200); // Debounce delay
    }

    // Capture analog values
    for (int i = 0; i < sampleSize; i++) {
        signalData[i] = analogRead(analogPin) / voltageScale; // Scale to OLED height
        delay(timeBase); // Adjust sampling delay (time base)
    }

    // Draw waveform
    display.clearDisplay();
    for (int x = 0; x < sampleSize - 1; x++) {
        display.drawLine(x, 64 - signalData[x], x + 1, 64 - signalData[x + 1], SSD1306_WHITE);
    }
    display.display();
}

This code initializes the OLED display and sets up the Arduino to read the potentiometer value on analog pin A0. It also monitors two digital input pins (D2 and D3) for button presses to adjust the time base and voltage scale of the waveform displayed on the OLED. The waveform is generated by reading the potentiometer value, scaling it, and plotting it on the display in a continuous loop.