HallSensor

はじめに

デジタルピンの入力で割り込みを発生させ、事前に登録した関数を呼び出します。

プログラム

定義等

1
2
3
4
//Simple sketch to access the internal hall effect detector on the esp32.
//values can be quite low. 
//Brian Degger / @sctv  
int val = 0;

ホールセンサの値を格納する変数valを定義しています。

setup()

5
6
7
8
void setup() {
  Serial.begin(9600);
    }
 

シリアルコンソールの初期設定です。ESP32で利用する通常の115200とは異なるので、実際に動かすときには注意が必要です。

loop()

 9
10
11
12
13
14
15
void loop() {
  // put your main code here, to run repeatedly:
  val = hallRead();
  // print the results to the serial monitor:
  //Serial.print("sensor = ");
  Serial.println(val);//to graph 
}

hallRead()によって読み取ったホールセンサの値を、シリアルコンソールに表示します。

バージョン

Hardware:ESP-WROOM-32
Software:Arduino core for the ESP32 2.0.4

最終更新日

September 4, 2022

inserted by FC2 system