#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
#define i2c_Address 0x3c //initialize with the I2C addr 0x3C
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define SCREEN_MIDDLE 32 // to display trace at screen middle
#define OLED_RESET -1
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
int xVal = 0; // trace location. left edge of OLED = 0
void setup() {
// Serial.begin(9600); // initialize serial communication
pinMode(A0, INPUT); // Setup for leads off detection LO +
pinMode(A1, INPUT); // Setup for leads off detection LO -
delay(250); // wait for the OLED to power up
display.begin(i2c_Address, true); // Address 0x3C default
// display.setTextColor(SH110X_WHITE); // TEXT color, not PIXEL color
display.clearDisplay(); // Clear the buffer.
display.display(); // display the buffer
}
void loop() {
int yVal = map(analogRead(A0), 0, 1023, 6, -6); // INPUT min/max
int zVal = map(analogRead(A1), 0, 1023, 1, 5); // AMPLITUDE adjust
display.drawLine(xVal, 0, xVal, 63, SH110X_BLACK); // verticle line to erase old trace
display.drawPixel(xVal - 1, SCREEN_MIDDLE + (yVal * zVal), SH110X_WHITE); // the trace
display.display();
xVal++; // move to next pixel
if (xVal == 128) { // if at OLED right edge
xVal = 0; // reset xVal to left edge
}
delay(10); // 10ms is about 2 seconds per trace, 25MS about 4 seconds
}
AMP MAP
+1 to +5
INPUT MAP
-6 to +6