其实上一篇是补的作业,顺便鄙视卓大的帖子都是文字,没有图片,听说可以用屏幕,就翻箱倒柜,可以一块屏幕都没找到,最后找到一块OLED的屏幕,据说升值了,管他呢,IIC接口的,好了就是它了
下边的代码稍做修改,只要是IIC的引脚要接对,没有RST随便写了一个
/*
* Copyright (c) 2012 Neal Horman - http://www.wanlink.com
*
* License: MIT open source (http://opensource.org/licenses/MIT)
* Summary;
* Use / modify / distribute / publish it how you want and
* if you use it, or don't, you can't hold me liable for how
* it does or doesn't work.
* If it doesn't work how you want, don't use it, or change
* it so that it does work.
*/
#include "mbed.h"
#include "Adafruit_SSD1306.h"
DigitalOut myled(LED1);
class I2CPreInit : public I2C
{
public:
I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl)
{
frequency(400000);
start();
};
};
I2CPreInit gI2C(I2C_SDA, I2C_SCL);
Adafruit_SSD1306_I2c gOled2(gI2C,D13,0x78,64,128);
int main()
{ uint16_t x=0;
gOled2.printf("%ux%u OLED Display\r\n", gOled2.width(), gOled2.height());
while(1)
{
myled = !myled;
gOled2.printf("%u\r",x);
gOled2.display();
x++;
wait(1.0);
}
}
| 有奖活动 | |
|---|---|
| 硬核工程师专属补给计划——填盲盒 | |
| “我踩过的那些坑”主题活动——第002期 | |
| 【EEPW电子工程师创研计划】技术变现通道已开启~ | |
| 发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
| 【EEPW在线】E起听工程师的声音! | |
| 高校联络员开始招募啦!有惊喜!! | |
| 【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
| 送您一块开发板,2025年“我要开发板活动”又开始了! | |