Skip to content

Instantly share code, notes, and snippets.

@cpmpercussion
Created December 26, 2014 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpmpercussion/a7ee6a69322ddd636c6d to your computer and use it in GitHub Desktop.
Save cpmpercussion/a7ee6a69322ddd636c6d to your computer and use it in GitHub Desktop.
Sketch for plotting an analog input on a MicroView arduino
#include <MicroView.h>
const int PLOT_PIN = 0;
int readingHistory[64];
int currentIndex = 0;
void setup() {
// put your setup code here, to run once:
uView.begin();
uView.clear(PAGE);
uView.print("\nready.");
uView.display();
delay(1000);
Serial.begin(9600);
}
void loop() {
// Read analog pin and update history
long reading = analogRead(PLOT_PIN);
reading = (reading * 48) / 1024;
readingHistory[currentIndex] = reading;
currentIndex = (currentIndex + 1) % 64;
// update the plot
uView.clear(PAGE);
for (int i = 0; i < 64; i++) {
uView.pixel(i, 48 - readingHistory[i]);
}
uView.display();
Serial.println(reading);
delay(5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment