OLEDs are pretty cool .
This is the standard Adafruit splash screen.
I think it demonstrates well the capabilities of these little windows.
I'm sure you've seen OLEDs in plenty of synths.
To get a better understanding of this technology, I've started mucking around with Arduinos, and various displays. LCDs are OK, but OLEDS are the bomb.
The Buchla logo is just lovely on this screen.
Up till now, all the images and text is part of the code.
In order to change the display, you need to change the code itself.
Thus this post.
It's actually a combination of two posts.
The first post covered how to read & display the voltage on
the output of an Arduino on a serial monitor.
The serial monitor is part of Arduino's IDE and communicates real time info.
The second post covered how to display info on a OLED screen.
So why not combine the two.
Though this may seem pretty basic, I think it's a important building block.
This is the code of how to read & display Arduino voltages on a OLED & the Serial monitor.
So so simple.
Feel free to copy, paste & hack
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// set up variables
int myVoltPin=A2;
int readVal;
float V2;
int delayT=250;
void setup()
{
Serial.begin(9600);
// initialize with the I2C addr 0x3C
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
// Clear the buffer.
display.clearDisplay();
}
void loop()
{
readVal=analogRead(myVoltPin);
V2=(5./1023.)*readVal;
// converts to a voltage -- remember to place the decimal
// points after the 5 & 1023 ... these may be floating points
Serial.println(V2);
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("Voltage");
display.println(" ");
display.setTextSize(3);
display.println(V2);
display.display();
delay(delayT);
display.clearDisplay();
}
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// set up variables
int myVoltPin=A2;
int readVal;
float V2;
int delayT=250;
void setup()
{
Serial.begin(9600);
// initialize with the I2C addr 0x3C
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
// Clear the buffer.
display.clearDisplay();
}
void loop()
{
readVal=analogRead(myVoltPin);
V2=(5./1023.)*readVal;
// converts to a voltage -- remember to place the decimal
// points after the 5 & 1023 ... these may be floating points
Serial.println(V2);
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("Voltage");
display.println(" ");
display.setTextSize(3);
display.println(V2);
display.display();
delay(delayT);
display.clearDisplay();
}
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
-------------------------------------------------------------------------------------------
---------------------------------
-------------------------------------
No comments:
Post a Comment