资源简介
TM1637数码管arduino库文件解决了四位数码管接线多,程序长的问题,对于开发者是一个很好的入门程序,程序能做很多方面的进化,时钟、计数器、温度显示器等等!!!

代码片段和文件信息
// Author: avishorp@gmail.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not write to the Free Software
// Foundation Inc. 51 Franklin St Fifth Floor Boston MA 02110-1301 USA
extern “C“ {
#include
#include
#include
}
#include
#include
#define TM1637_I2C_COMM1 0x40
#define TM1637_I2C_COMM2 0xC0
#define TM1637_I2C_COMM3 0x80
//
// A
// ---
// F | | B
// -G-
// E | | C
// ---
// D
const uint8_t digitToSegment[] = {
// XGFEDCBA
0b00111111 // 0
0b00000110 // 1
0b01011011 // 2
0b01001111 // 3
0b01100110 // 4
0b01101101 // 5
0b01111101 // 6
0b00000111 // 7
0b01111111 // 8
0b01101111 // 9
0b01110111 // A
0b01111100 // b
0b00111001 // C
0b01011110 // d
0b01111001 // E
0b01110001 // F
};
TM1637::TM1637(uint8_t pinClk uint8_t pinDIO)
{
// Copy the pin numbers
m_pinClk = pinClk;
m_pinDIO = pinDIO;
// Set the pin direction and default value.
// Both pins are set as inputs allowing the pull-up resistors to pull them up
pinMode(m_pinClk INPUT);
pinMode(m_pinDIOINPUT);
digitalWrite(m_pinClk LOW);
digitalWrite(m_pinDIO LOW);
BL(3);//如果不设置默认中间亮度,解决不先设置亮度无法显示
}
void TM1637::BL(uint8_t brightness)//0-7级亮度
{
m_brightness = brightness+8;
start();
writeByte(TM1637_I2C_COMM3 + (m_brightness & 0x0f));
stop();
}
void TM1637::setSegments(const uint8_t segments[] uint8_t length uint8_t pos)
{
// Write COMM1
start();
writeByte(TM1637_I2C_COMM1);
stop();
// Write COMM2 + first digit address
start();
writeByte(TM1637_I2C_COMM2 + (pos & 0x03));
// Write the data bytes
for (uint8_t k=0; k < length; k++)
writeByte(segments[k]);
stop();
}
void TM1637::Num(int num bool leading_zero uint8_t length uint8_t pos)
{
uint8_t digits[4];
const static int divisors[] = { 1 10 100 1000 };
bool leading = true;
for(int8_t k = 0; k < 4; k++) {
int divisor = divisors[4 - 1 - k];
int d = num / divisor;
if (d == 0) {
if (leading_zero || !leading || (k == 3))
digits[k] = encodeDigit(d);
else
digits[k] = 0;
}
else {
digits[k] = encodeDigit(d);
num -= d * divisor;
leading = false;
}
}
setSegments(digits + (4 - length) length pos);
}
void TM1637::bitDelay()
{
delayMicrosecond
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4029 2016-11-12 14:11 TM1637\examples\TM1637\TM1637.ino
文件 7632 2014-07-09 05:48 TM1637\LICENSE
文件 1392 2014-07-09 05:48 TM1637\README.md
文件 4715 2016-11-12 11:39 TM1637\TM1637.cpp
文件 2942 2016-11-12 10:54 TM1637\TM1637.h
目录 0 2016-11-12 14:17 TM1637\examples\TM1637
目录 0 2016-11-12 14:17 TM1637\examples
目录 0 2016-11-12 13:53 TM1637
----------- --------- ---------- ----- ----
20710 8
相关资源
- Visio图标-最新最全的网络通信图标库
- Python中Numpy库最新教程
- 60个HFSS 仿真模型库
-
st
yles 引文样式语言( CSL ) 引文样 - MoNyog8.5+破解补丁
- ANSYS LS-DYNA
- 全国4级地址库,京东数据
- 一个超简单的企业管理系统(带ACCE
- 数据库课设:图书管理系统报告
- 合同管理系统的源代码(附数据库)
- ado数据库MFC图书管理系统vs2010
- 先进先出库存管理excel表格.rar
- 在线题库管理
- 矩阵基本运算函数库
- 数据库VFP课程设计
- ADNS-3080光流传感器测试程序Arduino
- 服装店进销存管理系统
- 数据库实现学生成绩管理系统选课管
- 排队机叫号 源代码
- 【单片机】51单片机数码管显示万年历
- 课程作业:模拟仓库管理系统
- Access数据库在线编辑器
- STM32F103 DS18B20 V3.5.0固件库驱动程序工
- 25.数码管显示0-99
- Php 导出数据为EXCEL程序
- 人大金仓数据库系统表
- STC12C5A60S2 CH4521 驱动数码管 显示
- 伪原创同义词库(13000条)
- 模拟ATM柜员机系统--连接数据库
- 用工厂模式开发多数据库连接类
评论
共有 条评论