공부/arduino2018.04.09 16:25

esp32 spi OLED 돌리기

 

Esp32 Dev 에 SPI OLED 를 연결했다.

 

H/W 연결을 위해 보드 pin map 을 정했다.

 

 

위 pin map 을 아래와 같이 연결 했다.

 

 

참고 : 내부의 정의된 pin map

 

 

static const uint8_t SS    = 5;

static const uint8_t MOSI  = 23;

static const uint8_t MISO  = 19;

static const uint8_t SCK   = 18;

 

 

사용된 SOURCE

 

#include "Arduino.h"

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

 

//PIN define

#define OLED_PCLK     18
#define OLED_PDATA    23
#define OLED_PRESET   17
#define OLED_PCMD     16
#define OLED_PCS     5

#define LED 2

 

//Graphic define
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2

#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH  16

static const unsigned char PROGMEM logo16_glcd_bmp[] =
{ B00000000, B11000000,
  B00000001, B11000000,
  B00000001, B11000000,
  B00000011, B11100000,
  B11110011, B11100000,
  B11111110, B11111000,
  B01111110, B11111111,
  B00110011, B10011111,
  B00011111, B11111100,
  B00001101, B01110000,
  B00011011, B10100000,
  B00111111, B11100000,
  B00111111, B11110000,
  B01111100, B11110000,
  B01110000, B01110000,
  B00000000, B00110000 };


//SW SPI : (MOSI, CLK, DC, RESET, CS)
//Adafruit_SSD1306 display(OLED_PDATA, OLED_PCLK, OLED_PCMD, OLED_PRESET, OLED_PCS);  


//HW SPI : (DC, RST, CS)
Adafruit_SSD1306 display(OLED_PCMD, OLED_PRESET, OLED_PCS); 

 

//The setup function is called once at startup of the sketch

void setup()
{
 // Add your initialization code here
 pinMode(LED, OUTPUT);

 Serial.begin(115200);
 delay(10);

 

 // display.begin(SSD1306_SWITCHCAPVCC, 0x3D); //I2C

 display.begin(SSD1306_SWITCHCAPVCC); //SPI


 display.display();  //diplay output
 delay(2000);
 display.clearDisplay(); // Clear the buffer.

 

 Serial.println("Start..");
}

 

 

// The loop function is called in an endless loop
void loop()
{
 //Add your repeated code here
 digitalWrite(LED, 1);
 delay(1000);
 Serial.println("LED OFF");

 digitalWrite(LED, 0);
 delay(1000);
 Serial.println("LED ON");
}

 

 

 

 

 

 

'공부 > arduino' 카테고리의 다른 글

esp32 oled 한글 올리기  (0) 2018.04.12
esp32 아두이노 라이브러리 업그레이드  (0) 2018.04.12
esp32 spi OLED 돌리기  (0) 2018.04.09
ttgo Esp32 보드 sloeber 에서 돌리기  (0) 2018.04.09
esp32 ttgo 보드  (0) 2018.04.06
Esp32 환경 Sloeber Eclipse Arduino 옴기기  (0) 2018.04.05
Posted by 큰파도