Skip to content

setup, loop vs. main and while(1) #315

@Fox82

Description

@Fox82

Dear u8g2 supporters,

Why is this code for me working,

`
#include <Arduino.h>
#include <SPI.h>
#include <U8g2lib.h>

U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=/ U8X8_PIN_NONE, / clock=/ SCL, / data=*/ SDA);

void setup(void) {
u8g2.begin();
}

void loop(void) {
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_ncenB14_tr);
u8g2.drawStr(0,20,"Hello World!");
} while ( u8g2.nextPage() );
delay(1000);
}

`

and this one is not working! Display is blank. This is a big issue for me because with the switch from u8g to u8g2lib Display is not woring any more for my project.

`
#include <Arduino.h>
#include <SPI.h>
#include <U8g2lib.h>

U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=/ U8X8_PIN_NONE, / clock=/ SCL, / data=*/ SDA);

int main (void) {
u8g2.begin();

while(1){
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_ncenB14_tr);
u8g2.drawStr(0,20,"Hello World1");
} while ( u8g2.nextPage() );
delay(1000);
}
}
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions