差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン最新のリビジョン両方とも次のリビジョン | ||
p5js:13.grove_beginner_kit [2022/07/05 00:55] – [加速度センサ] baba | p5js:13.grove_beginner_kit [2022/07/05 13:11] – [加速度センサ] baba | ||
---|---|---|---|
行 309: | 行 309: | ||
//Gravity Acceleration | //Gravity Acceleration | ||
#include " | #include " | ||
- | |||
#include < | #include < | ||
+ | |||
LIS3DHTR< | LIS3DHTR< | ||
#define WIRE Wire | #define WIRE Wire | ||
- | |||
- | |||
void setup() { | void setup() { | ||
Serial.begin(9600); | Serial.begin(9600); | ||
行 332: | 行 330: | ||
Serial.print(LIS.getAccelerationY()); | Serial.print(LIS.getAccelerationY()); | ||
Serial.println(LIS.getAccelerationZ()); | Serial.println(LIS.getAccelerationZ()); | ||
- | |||
delay(500); | delay(500); | ||
} | } | ||
行 429: | 行 426: | ||
Serial.println(LIS.getAccelerationZ()); | Serial.println(LIS.getAccelerationZ()); | ||
- | delay(50); | + | delay(30); |
} | } | ||
行 436: | 行 433: | ||
</ | </ | ||
- | Arduino側のコードはdelayを50[ms]に変更しただけです。少しむずかしいと思いますが、じっくり読んでアルゴリズムを理解しましょう。 | + | Arduino側のコードはdelayを30[ms]に変更しただけです。少しむずかしいと思いますが、じっくり読んでアルゴリズムを理解しましょう。 |
さあ、それではセンサデータがしっかりと取得できたのでこの値で画面上のボールを転がしてみます。400x400のキャンバス上の真ん中からスタートし、x, | さあ、それではセンサデータがしっかりと取得できたのでこの値で画面上のボールを転がしてみます。400x400のキャンバス上の真ん中からスタートし、x, |