mirror of
https://github.com/m5stack/m5-docs.git
synced 2026-05-20 10:23:01 -07:00
3.3 KiB
3.3 KiB
ANGLE ユニット {docsify-ignore-all}
📝概要 :octocat:サンプルコード 🔌回路図 🛒購入リンク
概要
**ANGLE**ユニットはは10Kポテンショメータと呼ばれる抵抗器を搭載したユニットです。ポテンショメータは3端子の抵抗素子で、つまみを回すことで抵抗値を調整できます。ポテンショメータが回転すると、出力電圧値(Uo)が変化します。モーター速度、LEDの明るさなどの調整に使用できます。抵抗値の変化を下図に示します。
M5CoreのGROVE Bインターフェースに接続して、利用可能です。
特徴
パッケージ内容
- 1x ANGLEユニット
- 1x Groveケーブル
関連リンク
サンプルコード
1. Arduino
完全なソースコードはこちら。
画面にユニット出力電圧値に対応するデジタル値を表示します。 範囲は0~4095です。
#include <M5Stack.h>
// select the input pin for the potentiometer
int sensorPin = 36;
// last variable to store the value coming from the sensor
int last_sensorValue = 0;
// current variable to store the value coming from the sensor
int cur_sensorValue = 0;
void setup() {
M5.begin();
pinMode(sensorPin, INPUT);
M5.Lcd.setTextSize(2);
M5.Lcd.setCursor(0, 0);
M5.Lcd.print("the value of ANGLE: ");
}
void loop() {
// read the value from the sensor:
cur_sensorValue = analogRead(sensorPin);
M5.Lcd.setCursor(0, 25);
if(abs(cur_sensorValue - last_sensorValue) > 10){//debaunce
M5.Lcd.fillRect(0, 25, 100, 25, BLACK);
M5.Lcd.print(cur_sensorValue);
last_sensorValue = cur_sensorValue;
}
delay(50);
}
2. UIFlow
完全なソースコードはこちら。
回路図
ピンマップ
| M5Core(GROVE B) | GPIO36 | GPIO26 | 5V | GND |
| ANGLE Unit | Sensor Pin | 5V | GND |

