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 1 year has passed since last update.

STM32G031J6M6で4個のLEDでナイトライダー

Last updated at Posted at 2022-08-24

x 超超重要 なぜか秋月STM32G031J6M6がうり切れていた。注意!!(2022/8/27現在)

x 過去ログを見よ!!

x PA0をGPIOがわかる人むけ

目的
GPIOのテスト

o_con703.jpg

o_con684.jpg

参考



//GPIO_4LED_Knight_Rider_031_1

#include "mbed.h"

//1 LED1 PB_7
//2 VDD
//3 GND
//4 LED2 PA_0
//
//5 SWD
//6 SWD
//7 LED3 PA_12
//8 LED4 PA_11

//GPIOの初期化
DigitalOut  leds[]  = {
    DigitalOut (PB_7),  //LED1
    DigitalOut (PA_0),  //LED2
    DigitalOut (PA_12), //LED3
    DigitalOut (PA_11)  //LED4
};

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

    //not delete 3s wait
    wait_us(1000*1000);// 1秒待つ
    wait_us(1000*1000);// 1秒待つ
    wait_us(1000*1000);// 1秒待つ


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

        for(int ii=0; ii<=4; ii++) {

            for(int jj=0; jj<=4; jj++) {

                //GPIOへビットを設定
                if(ii == jj) {
                    leds[ jj ] = 1;
                } else {
                    leds[ jj ] = 0;
                }

            }//for

            wait_us(1000*1000);// 1秒待つ

        }//for

    }//while

}//main




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?