1
1

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 5 years have passed since last update.

Nefryでデジタル入力を試す!

Last updated at Posted at 2016-08-04

今回はD2ピンで入力を試してみます。

D2ピンはNefryのGrove端子に繋がっており、Groveで試すことも可能です!

Nefry.ino
#include <Nefry.h>

void setup() {
  pinMode(D2, INPUT); //D2のピンのデータを入力モードにします。
}
void loop() {
  int pinState;
  pinState = digitalRead(D2);
  if (pinState == HIGH) {
    Nefry.setLed(255, 0, 0); //LEDが赤色に光ります
    Nefry.println("HIGH");
  } else if (pinState == LOW) {
    Nefry.setLed(0, 0, 255); //LEDが青色に光ります
    Nefry.println("LOW");
  }
  Nefry.ndelay(250);
}
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?