#include #include /* * Basic test a Nokia 5110 display and the U8g2 library. * * Notes: * Program storage space and dynamic memory are the same whether you use HW or SW SPI. * With u8g_font_profont11, it uses 29% of program storage space and 24% of dynamic memory. * With u8g2_font_profont11_tr, it uses 25% of program storage space and 24% of dynamic memory. * With u8g2_font_fur30_tr, it uses 35% of program storage space and 24% of dynamic memory. */ /* * Pin assignments: * RST: 8 * CE/CS/SCE: 10 * DC/"D/C": 9 * DIN/DN/MOSI/DATA: 11 * CLK/SCLK/SCK: 13 * VCC: 3.3V * LIGHT/LED: ground through 330 ohm resistor * GND: ground */ const unsigned int CLOCK_PIN = 13, DATA_PIN = 11, CS_PIN = 10, DC_PIN = 9, RESET_PIN = 8; //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2 = U8G2_PCD8544_84X48_1_4W_SW_SPI(U8G2_R0, CLOCK_PIN, DATA_PIN, CS_PIN, DC_PIN, RESET_PIN); // SW SPI U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2 = U8G2_PCD8544_84X48_1_4W_HW_SPI(U8G2_R0, CS_PIN, DC_PIN, RESET_PIN); // HW SPI void setup() { u8g2.begin(); u8g2.setContrast(135); } void loop() { u8g2.firstPage(); do { // u8g2.setFont(u8g_font_profont11); // set a font u8g2.setFont(u8g2_font_profont11_tr); // u8g2.setFont(u8g2_font_fur30_tr); u8g2.drawStr(0, 15, "Nokia 5110"); // write a string at position X, Y u8g2.drawStr(0, 35, "Hello World!"); } while ( u8g2.nextPage() ); }