Atmega48A和TM1637驱动四位数码管

这段代码的功能是通过 TM1637 驱动的七段显示器进行基本的显示操作。它包括初始化显示器、显示静态和动态信息、以及在主循环中进行数字计数和状态指示。

//TM1637驱动代码

#define LIGHTON LOW
#define LIGHTOFF HIGH
#include <Thread.h>
#define LED1 7
#define LED2 10
#define LED3 2
#define BAT A7
#define KEY1 PD3
#define KEY2 PD4
#define OUT1 PB0
#define OUT2 PB1
#define OUT3 PD6 //CLK
#define OUT4 PD5  //DIO
#define IN1 14
#define IN2 15
#define IN3 16
#define IN4 17
#include "SevenSegmentTM1637.h"
#define OFF 0
#define ON 1
const byte PIN_CLK = OUT3;   // define CLK pin (any digital pin)
const byte PIN_DIO = OUT4;   // define DIO pin (any digital pin)
SevenSegmentTM1637    display(PIN_CLK, PIN_DIO);


void setup() {
           // initializes the Serial connection @ 9600 baud
  display.begin();            // initializes the display
  display.setBacklight(100);  // set the brightness to 100 %
  display.print("batt");      // display INIT on the display
  delay(100);                // wait 1000 ms
  display.clear();
  display.print(analogRead(A7));      // display INIT on the display
  delay(500);                // wait 1000 ms
  display.clear();
};

// run loop (forever)
void loop() {
  
  display.print("LOOP");                // display LOOP on the display
  delay(1000);                          // wait 1000 ms
  display.print("COUNTING SOME DIGITS");// print COUNTING SOME DIGITS
  display.clear();                      // clear the display
  for (uint8_t i=0; i < 100; i++) {     // loop from 0 to 100
    display.print(i);                   // display loop counter
    delay(100);                         // wait 100 ms
  };
  display.clear();                      // clear the display
  display.print("SUCC");                // print SUCC for success
  display.blink();                      // blink SUCC
  delay(1000);                          // wait 1000 ms
};

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值