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.

STM32G031と7セグで3分タイマー(STM32G031J6M6)

Last updated at Posted at 2021-02-12

STM32G031で3分タイマー

主要もモジュールは、秋月の約200円の7セグ

赤色7セグメントLEDシリアルドライバモジュール 完成品
[OSL10564-74HC595-R]
通販コード M-12642
発売日 2017/11/07
メーカーカテゴリ OptoSupply

[M-12642] 赤色7セグメントLEDシリアルドライバモジュール 完成品 通常在庫商品
1個 ¥215(税込)
https://akizukidenshi.com/catalog/g/gM-12642/
https://akizukidenshi.com/download/ds/akizuki/AE-7SEG-BOARD_a2.pdf

7セグで0から作るより秋月のを買ってね!!
インドの山奥(でんでんむし...)の様な人件費の安いところは、別!!

回路は、こちら
STM32G031J6M6のボードの作り方(STM32G031)
https://qiita.com/caa45040/items/f4120160e62ab5f690be



#include <Arduino.h>

//*          *****  *****  
//*         *       *    * 
//*         ******  *    *
//*         *       *    *
//*         *       *    *
//********   *****  *****

#define DW   digitalWrite

//#define swdclk   PA14 // 8pin
//#define swdio    PA13 // 7pin
#define swdclk   PA12 // 6pin
#define swdio    PA11 // 5pin
//#define t_led1   PA12 // 6pin
//#define t_led2   PA11 // 5pin
#define en       PA0  // 4pin
#define in7      PB7  // 1pin

char seg[32][8] = {
 { 1,1,1,1,1,1,1,1 }, //0 @ -> ' '
 { 0,0,0,0,0,1,0,1 }, //1 A  o
 { 1,1,0,0,0,0,0,1 }, //2 B      combined use "6"
 { 0,1,0,1,0,0,1,1 }, //3 C
 { 1,0,1,0,0,0,0,1 }, //4 D
 { 0,1,0,0,0,0,1,1 }, //5 E  o
 { 0,1,0,0,0,1,1,1 }, //6 F
 { 0,1,0,1,0,0,0,1 }, //7 G
 
 { 1,0,0,0,0,1,0,1 }, //8 H  o
 { 1,0,1,1,1,1,0,1 }, //9 I     combined use "1"
 { 1,0,1,1,0,0,0,1 }, //10 J
 { 0,1,0,0,0,1,0,1 }, //11 K 
 { 1,1,0,1,0,0,1,1 }, //12 L  o
 { 0,1,1,1,0,1,0,1 }, //13 M
 { 0,0,0,1,0,1,0,1 }, //14 N  o
 { 0,0,0,1,0,0,0,1 }, //15 O  o combined use "0"
 
 { 0,0,0,0,0,1,1,1 }, //16 P
 { 0,0,0,0,1,1,0,1 }, //17 Q combined use "9"
 { 1,1,1,0,0,1,1,1 }, //18 R
 { 0,1,0,0,1,0,0,1 }, //19 S combined use "5"
 { 1,1,0,0,0,0,1,1 }, //20 T
 { 1,0,0,1,0,0,0,1 }, //21 U
 { 1,1,1,1,0,0,0,1 }, //22 V
 { 1,0,0,1,1,0,1,1 }, //23 W  o
 { 1,1,0,0,1,1,0,1 }, //24 X
 
 { 1,0,0,0,1,0,0,1 }, //25 Y
 { 0,0,1,0,0,0,1,1 }, //26 Z combined use "2"
 { 0,0,1,0,1,0,0,1 }, //27 [  --> "3"
 { 1,0,0,0,1,1,0,1 }, //28 \  --> "4"
 { 0,0,0,1,1,1,0,1 }, //29 ]  --> "7"
 { 0,0,0,0,0,0,0,1 }, //26 ^  --> "8"
 { 1,1,1,1,1,0,1,1 }  //31 _
};

int vc;
int ch_chvc(int s)
{
        s = s - 64;
  
        vc =0;
        vc = vc | ((!(seg[s][7])) << 7);
        vc = vc | ((!(seg[s][3])) << 6);
        vc = vc | ((!(seg[s][2])) << 5);
        vc = vc | ((!(seg[s][4])) << 4);
        vc = vc | ((!(seg[s][5])) << 3);
        vc = vc | ((!(seg[s][6])) << 2);
        vc = vc | ((!(seg[s][1])) << 1);
        vc = vc | ((!(seg[s][0])) << 0);

        return(vc);
}

int v;
int rs;
void seg1()
{
    DW(swdio,(v>>7)&1);DW(swdclk,1);DW(swdclk,0); //7
    DW(swdio,(v>>6)&1);DW(swdclk,1);DW(swdclk,0); //6
    DW(swdio,(v>>5)&1);DW(swdclk,1);DW(swdclk,0); //5
    DW(swdio,(v>>4)&1);DW(swdclk,1);DW(swdclk,0); //4
    DW(swdio,(v>>3)&1);DW(swdclk,1);DW(swdclk,0); //3
    DW(swdio,(v>>2)&1);DW(swdclk,1);DW(swdclk,0); //2
    DW(swdio,(v>>1)&1);DW(swdclk,1);DW(swdclk,0); //1
    DW(swdio,(v>>0)&1);DW(swdclk,1);DW(swdclk,0); //0
    DW(swdio,rs);   
    DW(en,1);       delayMicroseconds(40);
    DW(en,0);       
}

void setup() {
  // put your setup code here, to run once:

    delay(3000); //not Delete

    pinMode(swdclk,OUTPUT);
    pinMode(swdio,OUTPUT);
    pinMode(en,OUTPUT);
    pinMode(in7,INPUT_PULLUP);

    DW(en,0);
    DW(swdio,0);
    for(int i=0;i<10;i++){
        DW(swdclk,1);
        delay(15);
        DW(swdclk,0);
        delay(15);
    } //for
}

int ii; //ループカウンター
void loop() {
  // put your main code here, to run repeatedly:

  v=ch_chvc('O');seg1();

  for(ii = 0;ii < 60;ii++){
    delay(1000);
  }

  v=ch_chvc('I');seg1();

  for(ii = 0;ii < 60;ii++){
    delay(1000);
  }

  v=ch_chvc('Z');seg1();

  for(ii = 0;ii < 60;ii++){
    delay(1000);
  }

  v=ch_chvc('[');seg1();

  while(1){} //無限ループ
}


7seg_031_y_1.jpg

7seg_031_y_2.jpg

7seg_b_g031_1.jpg

7seg_akizu_1.jpg

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?