LoginSignup
0
0

More than 3 years have passed since last update.

STM32G031J6M6とOLED、OLED096UNO-AでHello Worldを表示 STM32G031

Last updated at Posted at 2021-01-30

1.ardiuno ide 1.8.11にSTM32 Corasをインストール
2.u8g2ライブラリーをインストール
3.ソースの例からHelloWorldを選択
4.U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=/ PA8, / data=/ PA12, / reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display
を選択
5.PA8とPA12を設定


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

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ PA8, /* data=*/ PA12, /* reset=*/ U8X8_PIN_NONE);   // All Boards without Reset of the Display

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

void loop(void) {
  u8g2.clearBuffer();                   // clear the internal memory
  u8g2.setFont(u8g2_font_ncenB08_tr);   // choose a suitable font
  u8g2.drawStr(0,10,"Hello World!");    // write something to the internal memory
  u8g2.sendBuffer();                    // transfer internal memory to the display
  delay(1000);  
}

old_8x8_031_1.jpg

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0