I made a voltmeter and thermometer using the Atmega 328P - AU but a problem appeared! I want to provide power to the display by using the PB5 pin. However, no image is displayed here is my code:
// 128x32_OLED_Hello_World_u8glib
// based on the Olikraus u8glib library supporting I2C graphic displays
// public domain
#include <U8glib.h>
U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0);
void setup(void)
{
pinMode(5, OUTPUT); //configure PD5 pin as output
//Set font.
u8g.setFont(u8g_font_unifont);
u8g.setColorIndex(1); // display draws with pixel on
}
void loop(void)
{
digitalWrite(5, HIGH); //turn the display on
u8g.firstPage();
do {
draw();
} while (u8g.nextPage());
delay(50);
}
void draw(void)
{
u8g.setFont(u8g_font_helvB14); // font change – helvB14
u8g.drawStr(20, 13, "Hello");
u8g.setFont(u8g_font_unifont); // font change – standard
u8g.drawStr(20, 28, "World");
u8g.drawCircle (110, 15, 15); // contour
u8g.drawCircle (105, 14, 4); // left eye
u8g.drawCircle (115, 14, 4); // right eye
u8g.drawPixel (103,22); // mouth
u8g.drawPixel (118,22); // mouth
u8g.drawPixel (104,23); // mouth
u8g.drawPixel (117,23); // mouth
u8g.drawPixel (105,24); // mouth
u8g.drawPixel (116,24); // mouth
u8g.drawLine (106, 25, 115,25); // mouth
}
Can someone spot my mistake because it compiles just perfectly but there is no display output
?
