LED matrix analog plotter

The LED matrix is quite cool! I suggest to the Arduino team that they include on on the Minima in the future.

I made a simple analog plotter. It orients the matrix with the X asis along the power and analog pin edge of the matrix. I'm sure it would be simple to modify and use a different edge of the matrix if you like.


#include "Arduino_LED_Matrix.h"

ArduinoLEDMatrix matrix;

int maxX = 11;
int maxY = 7;
int minX = 0;
int minY = 0;

int Signal;
int Sample;


int frameDuration = 50;

byte frame[8][12] = {
  { 0,0,0,0,0,0,0,0,0,0,0,0 },
  { 0,0,0,0,0,0,0,0,0,0,0,0 },
  { 0,0,0,0,0,0,0,0,0,0,0,0 },
  { 0,0,0,0,0,0,0,0,0,0,0,0 },
  { 0,0,0,0,0,0,0,0,0,0,0,0 },
  { 0,0,0,0,0,0,0,0,0,0,0,0 },
  { 0,0,0,0,0,0,0,0,0,0,0,0 },
  { 0,0,0,0,0,0,0,0,0,0,0,0 },
};

void setup() {
  Serial.begin(115200);
  matrix.begin();
}

void loop() {
  sampleInput();
  advanceWaveform();
  matrix.renderBitmap(frame, 8, 12);
  delay(frameDuration);
}

void sampleInput(){
  Sample = analogRead(0);
  Sample = 1023 - Sample; // invert for matrix disply if you like
  Signal = Sample/128;  // scale to the matrix height
// always limit the singal so it won't get out of the frame
  if(Signal > maxY){ Signal = maxY; }
  if(Signal < minY){ Signal = minY; }
}

void advanceWaveform(){
  for(int y=0; y<=maxY; y++){
    for(int x=0; x<=maxX-1; x++){
      if(frame[y][x+1] == 1){
        frame[y][x] = 1;
        frame[y][x+1] = 0;
      } else {
        frame[y][x] = 0;
      }
    }
  }
  frame[Signal][maxX] = 1;
}
1 Like
byte frame[8][12];

Would have saved you a lot of typing.

1 Like

neat - thanks for sharing code

1 Like

lol
For sure! I posted code that had been poked and prodded for a while to get to work.
Yeah, strip the zero field and get a leaner code stub!