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.

Grove IoT スターターキット for SORACOM でボタンを使う

Last updated at Posted at 2021-08-04

ボタンを押すとLED が点灯するプログラムです。
ボタンの Grove を D38 に接続します。

grove-button/grove-button.ino
// ---------------------------------------------------------------
/*
	grove_button.ino

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

#define BUTTON_PIN	(WIOLTE_D38)
#define INTERVAL	  (100)

WioLTE Wio;

int icount = 0;
// ---------------------------------------------------------------
void setup()
{
	Wio.Init();	
	pinMode(BUTTON_PIN, INPUT);
}

// ---------------------------------------------------------------
void loop()
{
	int buttonState = digitalRead(BUTTON_PIN);
	SerialUSB.print(buttonState ? '*' : '.');

	if ((icount % 40) == 0)
		{
		SerialUSB.println("");
		}

	if (buttonState)
		{
		Wio.LedSetRGB(0, 0, 1);
		}
	else
		{
		Wio.LedSetRGB(0, 0, 0);
		}
		

	delay(INTERVAL);

	icount++;
}

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

実行時のシリアルモニターの様子
serial_monitor_aa.png

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?