Arduino-OLED-四度显示
double Fahrenheit(double celsius)
{
;
} //摄氏温度度转化为华氏温度
double Kelvin(double celsius)
{
return celsius + 273.15;
} //摄氏温度转化为开氏温度
// 露点(点在此温度时,空气饱和并产生露珠)
// 参考: http://wahiduddin.net/calc/density_algorithms.htm
double dewPoint(double celsius, double humidity)
{
double A0= 373.15/(273.15 + celsius);
);
SUM += 5.02808 * log10(A0);
SUM += -, (-/A0)))-) ;
SUM += ,(-)))-) ;
SUM += log10(1013.246);
, SUM-) * humidity;
double T = log(VP/0.61078); // temp var
return (241.88 * T) / (17.558-T);
}
// 快速计算露点,速度是5倍dewPoint()
// 参考: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
);
double Td = (b * temp) / (a - temp);
return Td;
}
static const unsigned char PROGMEM str_1[] =
{
0x00,0x08,0x43,0xFC,0x32,0x08,0x12,0x08,
0x83,0xF8,0x62,0x08,0x22,0x08,0x0B,0xF8,
0x10,0x00,0x27,0xFC,0xE4,0xA4,0x24,0xA4,
0x24,0xA4,0x24,0xA4,0x2F,0xFE,0x20,0x00,
};//温
static const unsigned char PROGMEM str_2[] =
{
0x01,0x00,0x00,0x84,0x3F,0xFE,0x22,0x20,
0x22,0x28,0x3F,0xFC,0x22,0x20,0x23,0xE0,
0x20,0x00,0x2F,0xF0,0x22,0x20,0x21,0x40,
0x20,0x80,0x43,0x60,0x8C,0x1E,0x30,0x04,
}; // 度
static const unsigned char PROGMEM str_3[] =
{
0x00,0x08,0x47,0xFC,0x34,0x08,0x14,0x08,
0x87,0xF8,0x64,0x08,0x24,0x08,0x0F,0xF8,
0x11,0x20,0x21,0x20,0xE9,0x24,0x25,0x28,
0x23,0x30,0x21,0x24,0x3F,0xFE,0x20,0x00,
}; //湿
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <dht11.h>
#include <DS3231.h>
#include <LiquidCrystal_I2C.h>
#include <RTClib.h>
dht11 DHT11;
#define DHT11PIN 2
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#define LOGO16_GLCD_HEIGHT 16 //定义显示高度
#define LOGO16_GLCD_WIDTH 16 //定义显示宽度
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
void printDateTime(DateTime dateTime);
//创建实例
RTC_DS1307 RTC;
DS3231 Clock;
bool Century=false;
bool h12;
bool PM;
uint8_t bell[] = {0x4,0xe,0xe,0xe,0x1f,0x0,0x4};
];
], Str_month[], Str_date[], Str_DoW[], Str_hour[], Str_minute[], Str_second[];
String recivedStr="";//接收到的字符串
;//接收到的字符个数
void setup() {
Serial.begin();
Wire.begin();
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64) //OLED 的I2C位置
// init done
display.clearDisplay();
////////////////
// Serial.println("Please enter the time: year[2]month[2]date[2]DoW[2]hour[2]minute[2]second[2]");
// Serial.println("example: 2014-12-3 Wednesday 14:15:15 enter:14120303141515");//1703072154
//英文字符显示
//display.setTextSize(1); //设置字体大小
//display.setTextColor(WHITE); //设置字体颜色白色
//display.setCursor(0,0); //设置字体的起始位置
//display.println(" zhongbest.com");//输出字符并换行
//display.display(); //把缓存的都显示
//初始化实时时钟
RTC.begin();
}
void loop() {
int chk = DHT11.read(DHT11PIN);
// Serial.print("Read sensor: ");
// switch (chk)
// {
// case DHTLIB_OK:
// Serial.println("OK");
// break;
// case DHTLIB_ERROR_CHECKSUM:
// Serial.println("Checksum error");
// break;
// case DHTLIB_ERROR_TIMEOUT:
// Serial.println("Time out error");
// break;
// default:
// Serial.println("Unknown error");
// break;
// }
display.clearDisplay();
//英文字符显示
display.setTextSize(); //设置字体大小
display.setTextColor(WHITE); //设置字体颜色白色
display.setCursor(,); //设置字体的起始位置
// display.print("Humidity(%):");
// display.println((float)DHT11.humidity, 2);
// display.print("Temperature(oC):");
// display.print("Temperature(oF):");
// display.println(Fahrenheit(DHT11.temperature), 2);
//
// display.print("Temperature(K):");
// display.println(Kelvin(DHT11.temperature), 2);
//
// display.print("Dew Point(oC):");
// display.println(dewPoint(DHT11.temperature, DHT11.humidity));
//
// display.print("Dew PointFast(oC):");
// display.println(dewPointFast(DHT11.temperature, DHT11.humidity));
//中文字符显示
display.drawBitmap(, , str_1, , , ); //在坐标X:26 Y:16的位置显示中文字符中
display.drawBitmap(, , str_2, , , ); //在坐标X:42 Y:16的位置显示中文字符贝
display.setCursor(,); //设置字体的起始位置
display.setTextSize(); //设置字体大小
display.print(":");
display.println(();
display.drawBitmap(, , str_3, , , ); //在坐标X:26 Y:16的位置显示中文字符中
display.drawBitmap(, , str_2, , , ); //在坐标X:42 Y:16的位置显示中文字符贝
display.setCursor(,); //设置字体的起始位置
display.setTextSize(); //设置字体大小
display.print(":");
display.println(();
int val;
val=analogRead();
// Serial.println(val,DEC);
display.setCursor(,); //设置字体的起始位置
display.print("MQ-2: ");
display.println(val,DEC);
// display.setCursor(0,60);
display.print("-------------------");
DateTime now = RTC.now();
//通过串口传送当前的日期和时间
printDateTime(now);
///////////////////////////////////////////////////////////
)//读取字符串
{
recivedStr += char(Serial.read());
// delay(2);
recivedNum = recivedNum+;
}
)
{ //year[2]month[2]date[2]DoW[2]hour[2]minute[2]second[2]
String strtemp = "";
strtemp = recivedStr.substring(,);
int years = strtemp.toInt();
RTC.set(RTC_YEAR,years);//设置年
strtemp = recivedStr.substring(,);
int months = strtemp.toInt();
RTC.set(RTC_MONTH,months);//设置月
strtemp = recivedStr.substring(,);
int days = strtemp.toInt();
RTC.set(RTC_DAY,days);//设置日
strtemp = recivedStr.substring(,);
int hours = strtemp.toInt();
RTC.set(RTC_HOUR,hours);//设置小时
strtemp = recivedStr.substring(,);
int minutes = strtemp.toInt();
RTC.set(RTC_MINUTE,minutes);//设置分钟
strtemp = recivedStr.substring(,);
int seconds = strtemp.toInt();
RTC.set(RTC_SECOND,seconds);//设置秒
recivedNum = ;
}
display.display(); //把缓存的都显示
delay();
}
void printDateTime(DateTime dateTime) {
//传送年份
display.setCursor(,); //设置字体的起始位置
display.print(dateTime.year(), DEC);
display.print('/');
//传送月份
display.print(dateTime.month(), DEC);
display.print('/');
//传送月份中的第几天
display.print(dateTime.day(), DEC);
display.print(' ');
//传送小时
display.print(dateTime.hour(), DEC);
display.print(':');
//传送分钟
display.print(dateTime.minute(), DEC);
display.print(':');
//传送秒
display.print(dateTime.second(), DEC);
display.display(); //把缓存的都显示
}
模块:
OLED12864显示屏:
模块针脚 Arduino针脚
VCC ----> 3.3V
GND ----> GND
SCL ----> A5
SDA ----> A4
烟雾传感器MQ-2:
VCC ----> 5V
GND ----> GND
A0 ----> A0
温湿度传感器DHT11:
+ ------> 5V
OUT ------> 2
- ------> GND
时钟模块DS1307:
SCL -------> A5
SDA -------> A4
VCC -------> 5V
GND -------> GND
Arduino-OLED-四度显示的更多相关文章
- 用STM32玩OLED(显示文字、图片、动图gif等)
目录 用STM32玩OLED(显示文字.图片.动图gif等) 1. 显示字符串 2. 显示中文 3. 显示图片 4. 显示动图 5. 总结测试 用STM32玩OLED(显示文字.图片.动图gif等) ...
- PMS5003ST+Arduino Nano OLED屏显示
整合OLED显示和PMS5003报数 #include <Arduino.h> #include <pms.h> /////////////////////////////// ...
- 东芝开发板驱动OLED模块显示LOGO图片
前言 在之前的两篇评测文章: 使用系统定时器SysTick实现精确延时微秒和毫秒函数 东芝MCU实现位带操作 介绍了系统SysTick实现精确延时,GPIO的输入输出使用,并实现了位带方式操作GPIO ...
- 树莓派使用 OLED 屏显示图片及文字
树莓派默认是不带显示屏的,如果想要查看系统的一些信息,需要使用电脑登录到树莓派,或者通过 HDMI 连接外接显示器查看.这样做总是有点麻烦,我们可以通过外接一个 OLED 屏来显示一些关键参数或者图片 ...
- 用Arduino显示颜色序列(u8g2,OLED)
目录 用Arduino显示颜色序列(u8g2,OLED) 用Arduino显示颜色序列(u8g2,OLED) 提前祝大家新年快乐! 主控:Arduino Mega 2560 硬件:126×64 OLE ...
- Arduino和C51开发OLED显示屏
技术:51单片机.Arduino.OLED显示屏.U8glib 概述 OLED显示屏常常用作为智能产品的显示设备,本文简单介绍OLED显示屏的使用方法. 详细 代码下载:http://www.de ...
- ESP8266开发之旅 应用篇② OLED显示天气屏
1.前言 这一篇,博主将教大家怎么去实现一个简易版本的天气助手. 先来一个博主已经实现功能的图片,如下: 1.1 知识储备 本篇需要用到以下知识点: 运用到ArduinoJso ...
- arduino驱动oled
OLED一款小巧的显示屏,感觉可以做出很可爱的东西. 这次实验的这款是128X64的OLED屏幕 , 芯片是SSD1306,请确认自家模块芯片型号,不然对不上号啊 使用IIC的方法,简单实验显示示例程 ...
- 基于STM32的脉搏心率检测仪(OLED可以实时显示脉冲波形)
—设计完整,功能可全部实现,有完整报告文档说明.程序以及pcb文件— 可作为:课程设计,STM32实践学习,电子制作等 设计所实现的功能: 利用STM32的AD采集功能实时采集心率传感器信号输出引脚输 ...
- MicroPython之TPYBoard v102开发板控制OLED显示中文
转载请以链接形式注明文章来源,公众号:MicroPython玩家汇 0x00前言 之前看到一篇文章是关于TPYBoardv102控制OLED屏显示的,看到之后就想尝试一下使用OLED屏来显示中文.最近 ...
随机推荐
- 利用VMware14安装虚拟机(Win7&CentOS6.4)
安装Win7 https://blog.csdn.net/Yangchenju/article/details/80694597 安装CentOS6.4 https://blog.csdn.net/u ...
- NOPI读取Word模板并保存
安装NPOI 可以在 程序包管理器控制台中输入 PM> Install-Package NPOI 会下载最新版本NPOI ----------------------------引用了NPOI- ...
- Arduino控制DTH11模块
一.接线原理图 二.实物图 三.事例代码 下载 git clone https://github.com/adafruit/DHT-sensor-library.git 放到 arduino-1.6. ...
- centos7下安装python3 解决openssl等一系列问题
最近折腾了下centos7,发现按正常方法安装python3.7后面会出现各种操蛋的问题. 主要的问题有三个,openssl版本过低,'_ctypes'缺失,以及安装后sqlite3缺失.下面我会贴出 ...
- Vue2 封装的 Quill 富文本编辑器组件 Vue-Quill-Editor
1.安装 npm install vue-quill-editor --save 2.使用 import { quillEditor } from 'vue-quill-editor' 3.组件中 & ...
- spring实现helloWord
第一步:添加架包 第二步:写一个简单的实列 package com.java.test; /** * @author nidegui * @create 2019-06-22 10:58 */ pub ...
- 启动模拟器的qq
#coding = utf-8from appium import webdriver '''1.手机类型2.版本3.手机的唯一标识 deviceName4.app 包名appPackage5.app ...
- 【例题 4-5 uva 512】Spreadsheet Tracking
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 每个操作对与一个点来说变化是固定的. 因此可以不用对整个数组进行操作. 对于每个询问,遍历所有的操作.对输入的(x,y)进行相应的变 ...
- 洛谷 P2764 LibreOJ 6002 最小路径覆盖问题
题目描述 «问题描述: 给定有向图G=(V,E).设P 是G 的一个简单路(顶点不相交)的集合.如果V 中每个顶点恰好在P 的一条路上,则称P是G 的一个路径覆盖.P 中路径可以从V 的任何一个顶点开 ...
- hdu 2897简单博弈
#include<stdio.h> int main() { int n,p,q,k; while(scanf("%d%d%d",&n,& ...