Newer
Older
M5StickCPlus_FactoryTest2022 / SampleSrc / analogread.ino
@motoki miura motoki miura on 6 Apr 2023 533 bytes use display
#include <M5StickCPlus.h>

int PIN = 26;

// +--- 15kΩ抵抗 --+-- CdSセル --+
// |              |             |
// GND           G26           3V3
// https://www.storange.jp/2012/03/arduinocds.html

// 注意点: https://lang-ship.com/reference/unofficial/M5StickC/Peripherals/ADC/

void setup() {
  M5.begin(115200);
  
  pinMode(PIN, ANALOG); // PINのモード設定
  
  // https://lang-ship.com/blog/work/m5stickc-io/
}

void loop() {
  Serial.printf("%04d\n", analogRead(PIN) ); // 暗 0〜4095 明
  
  delay(1000);
}