Hi!,
I'm trying to use a generic Ebay Oled display as a voltmeter whilst changing the voltage with a potentiometer for testing to use in a further project.
The display is working as it should until I try to use "u8g.print();" to display the voltage from a potentiometer, it works on serialprint but it keep saying "voltage was not declared" and I'm a little stuck now.. Here is the code;
#include "U8glib.h"
U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7);
void draw(void) {
u8g.setFont(u8g_font_9x15B);
u8g.drawStr( 0, 20, "Voltage");
u8g.setPrintPos(0, 50);
u8g.print(voltage);
}
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
Serial.println(voltage);
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
}
any idea's?