0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

4桁の7セグsegをarduinoでつかう

Posted at

はじめに

4桁の7セグをarduinoで使うためのメモです。
TM1637という制御チップで4端子で制御できます。

環境

arduino nano
Hiletgoの4桁7セグ
https://www.amazon.co.jp/gp/product/B010GX9CA4/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1

落とし穴

500円ぐらいのarduino nano互換機を使っていますが、いつの間にかに、書き込みが出来なくなっていました。が、ATmega328(Old Bootloader)を選択することで、書き込みできるようになりました。
image.png

配線

GND->GND
VCC->5V
DIO->D3
CLK->D2

ライブラリ

ライブラリの管理からAvishay Orpaz氏作のTM1637を入れます。バージョンは1.2.0でした。

image.png

コード

起動すると3分のカウントが始まり、03:00から00:00となって終わります。

3minTimer.ino
# include <Arduino.h>
# include <TM1637Display.h>

# define CLK 2
# define DIO 3
TM1637Display display(CLK, DIO);
 
void setup() {
}
 
void loop() {
    display.setBrightness(0x0f);
    display.showNumberDecEx(300,0x40,true);//0x40はコロン
    delay(1000);
    for(int i=59; i>=0; i--){
      display.showNumberDecEx(200+i,0x40,true);
      delay(1000);
    }
    for(int i=59; i>=0; i--){
      display.showNumberDecEx(100+i,0x40,true);
      delay(1000);
    }
    for(int i=59; i>=0; i--){
      display.showNumberDecEx(i,0x40,true);
      delay(1000);
    }
    while(true);
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?