LoginSignup
0
0

More than 1 year has passed since last update.

Grove IoT スターターキット for SORACOM でブザーをならす

Last updated at Posted at 2021-08-04

Grove IoT スターターキット for SORACOM でブザーをならす方法です。
Arduino で2次元配列を使うサンプルにもなっています。
ブザーの Grove は D38 に接続します。

grove-buzzer/grove-buzzer.ino
// ---------------------------------------------------------------
/*
    arduino_buzzer.ino

                    Aug/04/2021
*/
// ---------------------------------------------------------------
#include <WioLTEforArduino.h>

#define BUZZER_PIN      (WIOLTE_D38)
#define BUZZER_ON_TIME  (100)
#define BUZZER_OFF_TIME (500)

WioLTE Wio;

int led[5][3] = {{0,0,1},{0,1,0},{1,0,0},{1,1,0},{0,0,0}};

// ---------------------------------------------------------------
void setup()
{
    pinMode(BUZZER_PIN, OUTPUT);
    delay(500);
    Wio.Init();
}

// ---------------------------------------------------------------
void loop()
{
    for (int it=0; it<5; it++)
        {
        digitalWrite(BUZZER_PIN, HIGH);
        Wio.LedSetRGB(led[it][0],led[it][1],led[it][2]);
        delay(BUZZER_ON_TIME);

        digitalWrite(BUZZER_PIN, LOW);


        int time_delay = BUZZER_OFF_TIME * (it + 1);
        delay(time_delay);
        }
}

// ---------------------------------------------------------------

実行時の様子
IMG_20210804_165341.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