描述
For Micro:Bit, Arduino, Raspberry PI
I2C介面
OLED (Organic Light-Emitting Diode) 又稱為有機電激光顯示。具備輕、薄、省電壽命長等特性,這種顯示器在很多電子裝置(如MP3機)得到廣泛應用。
技術規格:
- 尺寸: 29.5mm x 27.35mm
- 屏幕尺寸: 0.96″
- 解像度: 128×64
- 可視角: >160°
- 功耗: 0.06W
- 溫度: -30 °C- 70°C
- 芯片: SSD1306
I2C接口:
- Vcc: 2.2V-5.5V
- GND: GND
- SCL: CLK時鐘
- SDA: MOSI數據
Arduino 使用教學:
http://www.instructables.com/id/Monochrome-096-i2c-OLED-display-with-arduino-SSD13/
Arduino Library:
https://github.com/adafruit/Adafruit-GFX-Library
https://github.com/adafruit/Adafruit_SSD1306
//使用時需更改 Adafruit_SSD1306.h 第73行:
//Modify Adafruit_SSD1306.h Line #73
#define SSD1306_128_64
// #define SSD1306_128_32
// #define SSD1306_96_16
Arduino 示範代碼:
Voltage Sensor https://gist.github.com/hkstemclub/29ceae2c1e0029fc025ac2ffb537c865
[pastacode lang=”markup” manual=”%2F*%0A%20%20Modify%20version%20of%20https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D7ph5ov56cfg%0A%20%20Code%20will%20be%20used%20to%20display%20a%20bar%20graph%20from%20measured%20input%20voltage%20from%20pin%20A0.%0A%20%20%0A%20%20The%20purpose%20of%20this%20program%20is%20to%20test%20and%20demonstrate%20the%20display%20performance%20of%20the%20128%20x%2064%20display%0A%20%20%0A%20%20The%20display%20is%20a%20Balance%20world%20Inc%200.96%22%20Inch%20Yellow%20and%20Blue%20I2c%20IIC%20Serial%20128×64%20Oled%20LCD%20Oled%20LED%20Module%20for%0A%20%20Arduino%20Display%2051%20Msp420%20Stim32%20SCR%0A%20%20This%20could%20tested%20with%20a%20Mega%20but%20should%20work%20with%20an%20UNO%0A%20%20Kit%20hkstem.club%0A%20%20Pin%20connections%0A%20%20Arduino%20%20%20device%0A%20%20A0%20%20%20%20Voltage%20read%20(10K%20pot%20across%20%2B5%2C%20and%20ground)%0A%20%20A1%0A%20%20A2%0A%20%20A3%0A%20%20A4%20%20%20%20SDA%20(if%20no%20SDA%20pin)%0A%20%20A5%20%20%20%20SCL%20(if%20not%20SCL%20pin)%0A%20%201%0A%20%202%0A%20%203%0A%20%204%0A%20%205%0A%20%206%0A%20%207%0A%20%208%0A%20%209%0A%20%2010%0A%20%2011%0A%20%2012%0A%20%2013%0A%20%20SDA%20%20%20SDA%0A%20%20SLC%20%20%20SLC%0A%20%20Graphics%20Libraries%0A%20%20https%3A%2F%2Fgithub.com%2Fadafruit%2FAdafruit-GFX-Library%0A%20%20https%3A%2F%2Fgithub.com%2Fadafruit%2FAdafruit_SSD1306%0A%20%20Modify%20Adafruit_SSD1306.h%20Line%20%2373%20to%20be%20like%0A%20%20%20%20%20%23define%20SSD1306_128_64%0A%2F%2F%20%20%20%23define%20SSD1306_128_32%0A%2F%2F%20%20%20%23define%20SSD1306_96_16%0A%20%20display%20buy%3A%0A%20%20http%3A%2F%2Fhkstem.club%2Fproduct%2F096oled%0A*%2F%0A%0A%23include%20%3CSPI.h%3E%0A%23include%20%3CWire.h%3E%0A%0A%23include%20%3CAdafruit_SSD1306.h%3E%0A%0A%23define%20OLED_RESET%204%0A%23define%20ADJ_PIN%20A0%0AAdafruit_SSD1306%20Display(OLED_RESET)%3B%0A%0Aint%20r%20%3D%200%3B%0Aint%20i%20%3D%200%3B%0A%0Avoid%20setup()%20%20%20%7B%0A%0A%0A%20%20Display.begin(SSD1306_SWITCHCAPVCC%2C%200x3C)%3B%20%20%2F%2F%20initialize%20with%20the%20I2C%20addr%200x3C%20(for%20the%20128×32)%0A%0A%20%20%2F%2F%20i’ll%20follow%20the%20license%20agreement%20and%20display%20the%20Adafruit%20logo%0A%20%20%2F%2F%20and%20since%20they%20were%20nice%20enough%20to%20supply%20the%20libraries%0A%20%20Display.clearDisplay()%3B%0A%20%20Display.display()%3B%0A%20%20delay%20(1000)%3B%0A%0A%20%20DrawTitles()%3B%0A%0A%7D%0A%0A%0Avoid%20loop()%20%7B%0A%0A%20%20%2F%2F%20get%20some%20dummy%20data%20to%20display%0A%0A%0A%20%20%2F%2Fr%20%3D%20rand()%20%2F%20220%3B%0A%20%20r%20%3D%20analogRead(ADJ_PIN)%3B%0A%20%20r%20%3D%20r%20%2F%207.98%3B%0A%0A%20%20Display.setTextSize(2)%3B%0A%20%20%2F%2F%20note%20set%20the%20background%20color%20or%20the%20old%20text%20will%20still%20display%0A%20%20Display.setTextColor(WHITE%2C%20BLACK)%3B%0A%20%20Display.setCursor(0%2C%2033)%3B%0A%20%20Display.println(Format(r%20*%207.99%20%2F%20204.6%20%2C%203%2C%202))%3B%0A%0A%20%20%2F%2Fdraw%20the%20bar%20graph%0A%20%20Display.fillRect(r%2C%2050%2C%20128%20-%20r%2C%2010%2C%20BLACK)%3B%0A%20%20Display.fillRect(3%2C%2050%2C%20r%2C%2010%2C%20WHITE)%3B%0A%0A%20%20for%20(i%20%3D%201%3B%20i%20%3C%2013%3B%20i%2B%2B)%20%7B%0A%20%20%20%20Display.fillRect(i%20*%2010%2C%2050%2C%202%2C%2010%2C%20BLACK)%3B%0A%20%20%7D%0A%0A%20%20%2F%2F%20now%20that%20the%20display%20is%20build%2C%20display%20it…%0A%20%20Display.display()%3B%0A%0A%0A%7D%0A%0A%0Avoid%20DrawTitles(void)%20%7B%0A%0A%20%20Display.setTextSize(2)%3B%0A%20%20Display.setTextColor(WHITE)%3B%0A%20%20Display.setCursor(0%2C%200)%3B%0A%20%20Display.println(%22Voltage%22)%3B%0A%0A%20%20Display.setTextSize(1)%3B%0A%20%20Display.setTextColor(WHITE)%3B%0A%20%20Display.setCursor(0%2C%2019)%3B%0A%20%20Display.println(%22hkstem.club%22)%3B%0A%20%20%2F%2FDisplay.println(%22Random%20number%22)%3B%0A%20%20Display.display()%3B%0A%0A%7D%0A%0A%0AString%20Format(double%20val%2C%20int%20dec%2C%20int%20dig%20)%20%7B%0A%0A%20%20%2F%2F%20this%20is%20my%20simple%20way%20of%20formatting%20a%20number%0A%20%20%2F%2F%20data%20%3D%20Format(number%2C%20digits%2C%20decimals)%20when%20needed%0A%0A%20%20int%20addpad%20%3D%200%3B%0A%20%20char%20sbuf%5B20%5D%3B%0A%20%20String%20fdata%20%3D%20(dtostrf(val%2C%20dec%2C%20dig%2C%20sbuf))%3B%0A%20%20int%20slen%20%3D%20fdata.length()%3B%0A%20%20for%20(%20addpad%20%3D%201%3B%20addpad%20%3C%3D%20dec%20%2B%20dig%20-%20slen%3B%20addpad%2B%2B)%20%7B%0A%20%20%20%20fdata%20%3D%20%22%20%22%20%2B%20fdata%3B%0A%20%20%7D%0A%20%20return%20(fdata)%3B%0A%0A%7D” message=”” highlight=”” provider=”manual”/]
Micro:bit 使用教學 https://makecode.microbit.org/pkg/Tinkertanker/pxt-oled-ssd1306
- Advanced -> Add Package -> https://github.com/Tinkertanker/pxt-oled-ssd1306
Micro:Bit Reference:
https://makecode.microbit.org/pkg/Tinkertanker/pxt-oled-ssd1306
https://hackernoon.com/the-first-video-game-on-the-bbc-micro-bit-probably-4175fab44da8
https://www.instructables.com/id/HackerBox-0022-BBC-MicroBit/
商品評價
目前沒有評價。