ESP8266-07

0.93存 液晶屏 128*64  驱动芯片 ssd1306

接线

VCC-5v

GND-GND

SCL-D1(SCL)

SDA-D2(SDA)

安装两个库

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

串口输入一句话

液晶屏幕显示出来

#include <SPI.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 // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 //4 Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); #define NUMFLAKES 10 // Number of snowflakes in the animation example #define LOGO_HEIGHT 16
#define LOGO_WIDTH 16 String comdata = ""; void oledint(){
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println("SSD1306 allocation failed");
for(;;); // Don't proceed, loop forever
}
Serial.println("success");
// Show initial display buffer contents on the screen --
// the library initializes this with an Adafruit splash screen.
display.display();
delay(2000); // Pause for 2 seconds // Clear the buffer
display.clearDisplay(); // Draw a single pixel in white
display.drawPixel(10, 10, WHITE); // Show the display buffer on the screen. You MUST call display() after
// drawing commands to make them visible on screen!
display.display();
delay(2000); // Invert and restore display, pausing in-between
display.invertDisplay(true);
delay(1000);
display.invertDisplay(false);
delay(1000); }
void setup() {
Serial.begin(9600);
while(Serial.read()>= 0){} //clear serialbuffer
oledint(); } void loop() { if(Serial.available()>0){
delay(100);
comdata = Serial.readString();
// Serial.print("Serial.readString:");
// Serial.println(comdata);
testdrawstyles(comdata);
}
comdata = ""; } String getValue(String data, char separator, int index)
{
int found = 0;
int strIndex[] = {0, -1};
int maxIndex = data.length()-1; for(int i=0; i<=maxIndex && found<=index; i++){
if(data.charAt(i)==separator || i==maxIndex){
found++;
strIndex[0] = strIndex[1]+1;
strIndex[1] = (i == maxIndex) ? i+1 : i;
}
} return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
} // x;31.112;y;31.123;z;23.3213;AP1;-23;AP2;-26;AP3;-21
void testdrawstyles(String msg) {
display.clearDisplay(); display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(0,0); // Start at top-left corner //display.println(msg);
display.println( "*-------------------*"); String part01 = getValue(msg,';',1);
display.print(F(" X : ")); display.println(part01); String part02 = getValue(msg,';',3);
display.print(F(" Y : ")); display.println(part02); String part03 = getValue(msg,';',5);
display.print(F(" Z : ")); display.println(part03); display.println( " ------------------- ");
String part04 = getValue(msg,';',7);
display.print(F("AP1: ")); display.println(part04); String part05 = getValue(msg,';',9);
display.print(F("AP2: ")); display.println(part05); String part06 = getValue(msg,';',11);
display.print(F("AP3: ")); display.println(part06); display.display();
delay(2000);
}

  

OLED液晶屏幕(4)串口读取文字并分割,液晶屏幕显示的更多相关文章

  1. OLED液晶屏幕(3)串口读取文字并分割

    https://blog.csdn.net/iracer/article/details/50334041 String comdata = ""; void setup() { ...

  2. [Arduino] 在串口读取多个字符串,并且转换为数字数组

    功能如题目.在串口收到逗号分割的6串数字比如100,200,45,4,87,99然后在6个PWM端口3, 5, 6, 9, 10, 11输出对应PWM值代码注释很详细了,就不再说明了. //定义一个c ...

  3. Arduino学习笔记A6(补充) - 在串口读取多个字符串,并且转换为数字数组

    功能如题目. 在串口收到逗号分割的6串数字比如 100,200,45,4,87,99 然后在6个PWM端口3, 5, 6, 9, 10, 11输出对应PWM值 代码注释很详细了,就不再说明了. ARD ...

  4. VS编程,C#串口通讯,通过串口读取数据的一种方法

    一.可能需要的软件:1.虚拟串口vspd(Virtual Serial Port Driver,用来在电脑上虚拟出一对串口,模拟通讯. 2.友善串口调试助手,用来发送.读取数据. 二.思路1.查询本机 ...

  5. 一篇提及如何通过串口读取并提取GPS信号的论文

    一篇提及如何通过串口读取并提取GPS信号的论文 作者:崔杰 梁计春 王国军 目前,在用计算机进行数据传输时,常用的是串行通信方式.在Visual C++的编程中,既可以用Windows API函数进行 ...

  6. C# 从串口读取数据

    最近要做系统集成,需要从串口读取数据,随学习一下相关知识: 以下是从串口读取数据 public static void Main() { SerialPort mySerialPort = new S ...

  7. labview初始学习过程中遇到串口读取框红蓝色交替闪烁的处理

           labview工程的程序框图VISA串口读取框红蓝交替闪烁,前面板接收数据错乱,或者是接受不了,这是你不小心设置了断点.

  8. SPLIT(文字列の分割)

    概要 SPLIT命令は特定の文字で値を分割する命令だ.タブ区切りや.カンマ区切り等のファイルからデータを取得し値を各項目に振り分けたい時に使用する事が多いだろう.また.XMLファイル等を使用してインタ ...

  9. Python + opencv 实现图片文字的分割

    实现步骤: 1.通过水平投影对图形进行水平分割,获取每一行的图像: 2.通过垂直投影对分割的每一行图像进行垂直分割,最终确定每一个字符的坐标位置,分割出每一个字符: 先简单介绍一下投影法:分别在水平和 ...

随机推荐

  1. JVM 配置常用参数和常用 GC 调优策略

    链接:https://juejin.im/post/5c94a123f265da610916081f   JVM 配置常用参数 堆参数 回收器参数 如上表所示,目前主要有串行.并行和并发三种,对于大内 ...

  2. JSON学习(三)

    案例: * 校验注册用户名是否存在 在注册页面,填写完用户名且该栏失去焦点时,前端会进行ajax传输该内容与后台数据库进行比对, 若数据库中没有该用户名,则用户栏后显示“用户名可用”,反之,则显示&q ...

  3. FastReport For Delphi7 通用安装方法

    安装前请册除原有的FR控件. 1. "Tools|Environmet options..."中的"Library"标签面下"Library path ...

  4. golang微服务框架go-micro 入门笔记1.搭建 go-micro环境

    微服务的本质是让专业的人做专业的事情,做出更好的东西. golang具备高并发,静态编译等特性,在性能.安全等方面具备非常大的优势.go-micro是基于golang的微服务编程框架,go-micro ...

  5. Ubuntu 固定自己的IP

    使用以下命令 sudo vi /etc/network/interfaces 以下方文件内容进行覆盖 ​# interfaces(5) file used by ifup(8) and ifdown( ...

  6. 从损失函数优化角度:讨论“线性回归(linear regression)”与”线性分类(linear classification)“的联系与区别

    1. 主要观点 线性模型是线性回归和线性分类的基础 线性回归和线性分类模型的差异主要在于损失函数形式上,我们可以将其看做是线性模型在多维空间中“不同方向”和“不同位置”的两种表现形式 损失函数是一种优 ...

  7. Drools 规则文件语法概述

    概述(Overview) 以.drl为扩展名的文件,是Drools中的规则文件,规则文件的编写,遵循Drools规则语法.下面详细介绍一下Drools规则文件语法.具体参考官方文档: https:// ...

  8. React+SpringBoot项目部署

    静态资源访问配置 https://www.jianshu.com/p/b6e0a0df32ec https://segmentfault.com/q/1010000012240531/a-102000 ...

  9. C# vb .net实现圆角矩形特效滤镜

    在.net中,如何简单快捷地实现Photoshop滤镜组中的圆角矩形效果呢?答案是调用SharpImage!专业图像特效滤镜和合成类库.下面开始演示关键代码,您也可以在文末下载全部源码: 设置授权 第 ...

  10. Mars Sample 使用说明

    Mars Sample 使用说明  https://github.com/Tencent/mars/wiki/Mars-sample-%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98 ...