Created
December 26, 2014 05:41
-
-
Save cpmpercussion/a7ee6a69322ddd636c6d to your computer and use it in GitHub Desktop.
Sketch for plotting an analog input on a MicroView arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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