brothore 发表于 2015-12-31 22:55:30

求助SSD1306的oled点不亮


刚刚到手的,如图


我用的是uno
clk接了13 mosi接了12 dc接了9 cs接了8

代码


#include "U8glib.h"
U8GLIB_SSD1306_128X64 u8g(13, 12, 9, 8);

void draw(void) {

u8g.setFont(u8g_font_unifont);

u8g.drawStr( 0, 22, "Hello World!");
}

void setup(void) {
   

if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);   // white
}
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setColorIndex(3);         // max intensity
}
else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setColorIndex(1);         // pixel on
}
else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB(255,255,255);
}
}

void loop(void) {
// picture loop
u8g.firstPage();
do {
    draw();
} while( u8g.nextPage() );
   
// rebuild the picture after some delay
delay(50);
}

oled没反应 TAT

商品链接
https://item.taobao.com/item.htm?spm=a1z09.2.0.0.QS5c82&id=40534977779&_u=v4ovuec2d71

林定祥 发表于 2015-12-31 23:54:01

最好用卖方,有时发光板后电路不一样所用的驱动也不一样的。

老来疯 发表于 2016-1-1 23:43:21

本帖最后由 老来疯 于 2016-1-1 23:47 编辑

U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);        // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9

u8g的这个驱动语句 是属于软件模拟 SPI 驱动方式,对于括号里面的引脚编号不做限制,只要是数字端口就行,但是,他的 引脚编号顺序必须正确,就像他在 其后的 注释语句里 说明的那样,不能搞错。

括号里面的数字按顺序: 1. SCK= 时钟,2.MOSI=主出从入,3.CS=片选 也称 SS,你的屏是 CS1,   4.A0=数据/命令 也称 DC,

你把第 3和 第 4 脚 接反了。

ethan42411 发表于 2016-1-3 11:09:50

你的接腳是不是沒有焊接啊

lovezypj 发表于 2016-1-8 13:56:23

我的oled是iic的,用u8glib也是死活不亮,用卖家提供的Adafruit_ssd1306就可以点亮,我也没找到原因
我还在继续试验中

甲子如风 发表于 2016-12-27 08:20:53

lovezypj 发表于 2016-1-8 13:56
我的oled是iic的,用u8glib也是死活不亮,用卖家提供的Adafruit_ssd1306就可以点亮,我也没找到原因
我还 ...

同病相怜感觉Adafruit_ssd1306简单多了

sandurlqh 发表于 2017-1-22 23:29:06

楼主买了不看说明书吗?这个液晶板采用spi接线,必须知道ret重启键的引脚,否则永远点不亮。

galaxy 发表于 2017-2-20 14:51:15

本帖最后由 galaxy 于 2017-2-20 14:57 编辑

// 必需用 1.0版才能過

#include "U8glib.h"

// setup u8g object, please remove comment from one of the following constructor calls
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device

//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);       // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);       // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);       // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);       // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGS102 u8g(13, 11, 10, 9);                  // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGM132 u8g(13, 11, 10, 9);                  // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGM128 u8g(13, 11, 10, 9);                  // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_ST7920_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, U8G_PIN_NONE, U8G_PIN_NONE, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_128X64 u8g(18, 16, 17, U8G_PIN_NONE);                  // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_ST7920_192X32 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, U8G_PIN_NONE, U8G_PIN_NONE, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_192X32 u8g(18, 16, 17, U8G_PIN_NONE);                  // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_ST7920_192X32 u8g(13, 11, 10, U8G_PIN_NONE);                  // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
//U8GLIB_ST7920_192X32 u8g(10, U8G_PIN_NONE);                  // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
//U8GLIB_LM6059 u8g(13, 11, 10, 9);                  // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_LM6063 u8g(13, 11, 10, 9);                  // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGXL160_BW u8g(10, 9);            // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);             // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);            // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);             // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);                  // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);                  // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11,4, 5, 6, 7,17, 14, 15, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 wr=en=17, cs=14, a0=di=15,rd=U8G_PIN_NONE,reset=16
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); ; // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);             // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_SSD1306_128X64 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins areSCK = 13 and MOSI = 11)
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);                  // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);             // I2C
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);             // I2C
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);                  // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);                  // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8

U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); //這一行就是定義 SSD1306 的介面方式

void draw(void) {
// graphic commands to redraw the complete screen should be placed here

// assign default font
u8g.setFont(u8g_font_unifont);

// pointer to strings in flash memory can be stored in a special type
const __FlashStringHelper *flash_ptr;

// the result of the F() macro can be assigned to this pointer
flash_ptr = F("Hello World!");

// this pointer can be used as argument to the draw procedures
u8g.drawStr( 0+1, 20+1, flash_ptr);
u8g.drawStr( 0, 20, flash_ptr);

// of course, the F() macro can be used directly
u8g.drawStr( 0, 40, F("PROGMEM"));

}

void setup(void) {
// flip screen, if required
// u8g.setRot180();
}

void loop(void) {
// picture loop
u8g.firstPage();
do {
    draw();
} while( u8g.nextPage() );

// rebuild the picture after some delay
delay(500);
}


這是 u8g 庫裡面的範例,我試過可以用 (iic 的 SSD1306 可以正常顯示)
页: [1]
查看完整版本: 求助SSD1306的oled点不亮