1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

M5Stamp S3でアナログ入力して遊ぶ(電圧表示)

Last updated at Posted at 2024-09-05

x 過去ログをみよ

結果

o_coq370.jpg

o_coq371.jpg

プログラム




//dennatu_hennkan1_S3_1


//定義
#define ADC1 15


//初期化
void setup() {

  //シリアルポートの初期化
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);

  //GPIOの初期化
  //アナログ入力の時は、特になし

}//setup


//メインループ
void loop() {

  int sensorValue; //センサーの読み取り値
  int Voltage;     //電圧

  //センサーから値を読み込む
  sensorValue = analogRead(ADC1); //S3

  //センサーの値から電圧に変換
  Voltage = (sensorValue * 3300) >> 12; //4096step-adc  (>>12)=(/4096) [S3]

  //電圧を表示
  Serial.print(Voltage);
  Serial.print("mV");
  Serial.println();

  delay(500);//0.5秒待つ

}//loop



1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?