デジタルピンの入力で割り込みを発生させ、事前に登録した関数を呼び出します。
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を定義しています。
5 6 7 8
void setup() { Serial.begin(9600); }
シリアルコンソールの初期設定です。ESP32で利用する通常の115200とは異なるので、実際に動かすときには注意が必要です。
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()によって読み取ったホールセンサの値を、シリアルコンソールに表示します。
September 4, 2022