いろんなセンサやデバイスをためそう

GROVE - RGB LED(Chainable LED)

https://www.switch-science.com/products/3375?pr_prod_strat=e5_desc&pr_rec_id=99d8c8609&pr_rec_pid=7675700019398&pr_ref_pid=7675355168966&pr_seq=uniform

https://wiki.seeedstudio.com/Grove-Chainable_RGB_LED/

https://github.com/pjpmarques/ChainableLED

image.png

RGB LEDは、特に多数のLEDが同時に点灯すると、鮮やかで幻想的な光の効果を生み出します。しかし、そのようなLEDプロジェクトを構築するには、すべてのLEDを接続するのは容易ではありません。そこで、SeeedのGrove-Chainable RGB LED V2.0を試してみてはいかがでしょうか。

Grove-Chainable RGB LED V2.0は、P9813S14チップをベースにしています。このチップは、3つの定電流ドライバと256階調のグレースケール変調出力を備えたフルカラー光源ドライバチップです。MCUとの通信は2線式(データとクロック)で行います。この2線式伝送により、Grove-Chainable RGB LEDモジュールを複数台カスケード接続できます。内蔵のクロック再生機能により、伝送距離が延長されます。

この製品のキーワードは「Chainable(連結可能)」ですが、一体いくつのLEDを連結できるのでしょうか?あるLEDの出力溝コネクタを別のLEDの入力溝コネクタに接続することで、最大1024個のRGB LEDを連結できます

https://github.com/pjpmarques/ChainableLED/tree/master/examples sample code

ChainableLED leds(7, 8, NUM_LEDS);の場合はD8に指すこと

Grove - SI1151搭載 太陽光センサ

https://www.switch-science.com/products/7005?_pos=1&_sid=2fe023591&_ss=r

https://wiki.seeedstudio.com/Grove-Sunlight_Sensor/

https://github.com/Seeed-Studio/Grove_Sunlight_Sensor

image.png

sample code

https://github.com/Seeed-Studio/Grove_Sunlight_Sensor/tree/master/examples


Grove - スピーカープラス

https://www.switch-science.com/products/7007?_pos=1&_sid=aa533ea80&_ss=r

https://wiki.seeedstudio.com/Grove-Speaker-Plus/

image.png

/*macro definition of Speaker pin*/
#define SPEAKER 3

int BassTab[]={1911,1702,1516,1431,1275,1136,1012};//bass 1~7

void setup()
{
    pinInit();
}
void loop()
{
        /*sound bass 1~7*/
    for(int note_index=0;note_index<7;note_index++)
    {
        sound(note_index);
        delay(500);
    }
}
void pinInit()
{
    pinMode(SPEAKER,OUTPUT);
    digitalWrite(SPEAKER,LOW);
}
void sound(uint8_t note_index)
{
    for(int i=0;i<100;i++)
    {
        digitalWrite(SPEAKER,HIGH);
        delayMicroseconds(BassTab[note_index]);
        digitalWrite(SPEAKER,LOW);
        delayMicroseconds(BassTab[note_index]);
    }
}

D3に指すこと

Grove-高精度気圧センサDPS310

https://www.switch-science.com/products/6286?_pos=1&_sid=2ea406902&_ss=r

https://wiki.seeedstudio.com/Grove-High-Precision-Barometric-Pressure-Sensor-DPS310/

https://wiki.seeedstudio.com/ja/Grove-High-Precision-Barometric-Pressure-Sensor-DPS310/

I2Cにさすこと。

https://github.com/Infineon/DPS310-Pressure-Sensor

#include <Dps310.h>

Dps310 Dps310PressureSensor = Dps310();

void setup()
{
  Serial.begin(9600);
  while (!Serial);
  Dps310PressureSensor.begin(Wire);
  Serial.println("初期化完了!");
}

void loop()
{
  float Detection_array[10];
  uint8_t oversampling = 7;
  int16_t ret;
  int i;
  int size = 10;
  int state1;
  int state2;
/* 以下の2つのループでは、それぞれ前後の時間での圧力状態を検出します。
   サンプリング数は10です。大きな偏差のある値を除外し、平均値を計算します。*/
      ret = Dps310PressureSensor.measurePressureOnce(Detection_array[0], oversampling);
      state1 = Detection_array[0];
 for (i = 1; i < 9; i++)
  {
     ret = Dps310PressureSensor.measurePressureOnce(Detection_array[i], oversampling);
       if (Detection_array[i] - Detection_array[i - 1] < 5)
      {
        state1 += Detection_array[i];
      }
      else
      {
        size -= 1;
      }
  } 
 state1 = state1 / size;
 delay(100);

      ret = Dps310PressureSensor.measurePressureOnce(Detection_array[0], oversampling);
      state2 = Detection_array[0];
 for (i = 1; i < 9; i++)
  {
      ret = Dps310PressureSensor.measurePressureOnce(Detection_array[i], oversampling);
      if (Detection_array[i] - Detection_array[i - 1] < 5)
      {
        state2 += Detection_array[i];
      }
      else
      {
        size -= 1;
      }
  }
  state2 = state2 / size;
  
 if (ret != 0)
   {
    Serial.print("失敗! ret = ");
    Serial.println(ret);
   }
/* 気圧の差を計算して、転倒したかどうかを判断します */
    else if (state2 - state1 > 4)
     {
      Serial.println("転倒しました。助けが必要ですか?");
      delay(5000);
     }
    else
      Serial.println("大丈夫です!");
}


Grove - スライドポテンショメータ

Grove - スライドポテンショメータ

https://www.switch-science.com/products/1050

https://wiki.seeedstudio.com/ja/Grove-Slide_Potentiometer/

image.png

int adcPin = A0; // ポテンショメーターの入力ピンを選択
int ledPin = A1; // LEDのピンを選択
int adcIn = 0;   // センサーからの値を格納する変数
void setup()
{
Serial.begin(9600); // シリアル通信を9600bpsで初期化
pinMode(ledPin, OUTPUT); // ledPinをOUTPUTに設定
Serial.println("スライドポテンショメーターテストコード!!");
}
void loop()
{
// センサーから値を読み取る:
adcIn = analogRead(adcPin);
if(adcIn >= 500) digitalWrite(ledPin,HIGH);  // adcInが500以上の場合、LEDを点灯
else digitalWrite(ledPin, LOW);
Serial.println(adcIn);
delay(100);
}

ここに追加