2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

XIAO ESP32C6+SSD1306、高さ3の線を書いて遊ぶ(例題)

Posted at

目的

点に分解して線を書く

アイディアの基本は、分割した単位に達するとYを1UPする

結果

o_coq890.jpg

プログラム



//OLED_SSD1331_line_0_XIAO_ESP32C6


//ヘッダーファイル
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>


//定義
#define SCREEN_WIDTH 128     // OLED display width, in pixels
#define SCREEN_HEIGHT 64     // OLED display height, in pixels
#define OLED_RESET -1        // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C  ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);


//初期化
void setup() {

  //I2Cの初期化
  Wire.begin(D9, D10);  //XIAO ESP32C6+SSD1306
  //Wire.begin(D10,D9); //XIAO ESP32C6+GROVE

  // I2Cアドレスは使用するディスプレイに合わせて変更する
  display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);

}  //setup


//メインループ
void loop() {

  // 画面表示をクリア
  display.clearDisplay();

  int o = (60 / 3);
  int p = o;
  int y = 0;

  for (int x = 0; x < 60; x++) {
    if (x > p) {
      y = y + 1;
      p = p + o;
      display.display();
      delay(750);
    }  //if
    display.drawPixel(x, y, WHITE);
  }  //for

  // 描画バッファの内容を画面に表示
  display.display();

  delay(5000);  //5秒待つ

}  //loop



2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?