LoginSignup
0
0

More than 1 year has passed since last update.

LPC812MAXと秋月シリアル7セグで3分タイマー SPI

Last updated at Posted at 2022-09-09

x mbed2リビジョン144
x リビジョンの変更ができる人むけ

x 赤色7セグメントLEDシリアルドライバモジュール 完成品
x OSL10564-74HC595-R M-12642

o_con735.jpg

o_con736.jpg



//spi_7seg_3min_812_1

#include "mbed.h"

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

//SPIとGPIOの設定
SPI spi( P0_14, P0_15, P0_12);   // mosi, miso, sclk //812
DigitalOut en( P0_13 ); //812

//7セグ表示パターン
char seg[32] = {
    0x00,  //0 @ -> ' '
    0x77,  //1 A  o
    0x7c,  //2 B      combined use "6"
    0x39,  //3 C
    0x5e,  //4 D
    0x79,  //5 E  o
    0x71,  //6 F
    0x3d,  //7 G

    0x76,  //8 H  o
    0x06,  //9 I     combined use "1"
    0x1e,  //10 J
    0x75,  //11 K
    0x38,  //12 L  o
    0x15,  //13 M
    0x37,  //14 N  o
    0x3f,  //15 O  o combined use "0"

    0x73,   //16 P
    0x67,   //17 Q combined use "9"
    0x50,   //18 R
    0x6d,   //19 S combined use "5"
    0x78,   //20 T
    0x3e,   //21 U
    0x1c,   //22 V
    0x2a,   //23 W  o
    0x64,   //24 X

    0x6e,   //25 Y
    0x5b,   //26 Z combined use "2"
    0x4f,   //27 [  --> "3"
    0x66,   //28 \  --> "4"
    0x27,   //29 ]  --> "7"
    0x7f,   //26 ^  --> "8"
    0x08    //31 _
};

//60秒の待ち
int ii; //ループカウンター
#define s60()   for(ii=0;ii<60;ii++)wait_ms(1000);

//メイン関数
int main()
{

    //SPIの設定
    spi.format(8,0);
    spi.frequency(1000000);

    //ラッチをLOWにする。
    en=0;

    //0分
    spi.write(0);
    spi.write(0);
    spi.write(0);
    spi.write(seg['O'-64]);
    en=1;
    en=0;
    s60();

    //1分
    spi.write(0);
    spi.write(0);
    spi.write(0);
    spi.write(seg['I'-64]);
    en=1;
    en=0;
    s60();

    //2分
    spi.write(0);
    spi.write(0);
    spi.write(0);
    spi.write(seg['Z'-64]);
    en=1;
    en=0;
    s60();

    //3分
    spi.write(0);
    spi.write(0);
    spi.write(0);
    spi.write(seg['['-64]);
    en=1;
    en=0;

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

}//main



o_con833.jpg

-18-

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