Newer
Older
m5stickcplus / src / analogread.ino
@Motoki Miura Motoki Miura on 3 Mar 2021 544 bytes week1
#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();

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

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