diff --git a/SampleSrc/cds01.ino b/SampleSrc/cds01.ino index 8cfede4..0c61a64 100644 --- a/SampleSrc/cds01.ino +++ b/SampleSrc/cds01.ino @@ -1,20 +1,40 @@ +#include + +#define USE_DISPLAY + int PIN = 26; // +--- 15kΩ抵抗 --+-- CdSセル --+ -// | | | -// GND G26 3V3 +// | | | +// GND G26 3V3 // https://www.storange.jp/2012/03/arduinocds.html // 注意点: https://lang-ship.com/reference/unofficial/M5StickC/Peripherals/ADC/ void setup() { + #ifdef USE_DISPLAY + M5.begin(); + M5.Lcd.setRotation(3); + #else Serial.begin(115200); //M5.beginを使わずにシリアルを使う場合 + #endif + pinMode(PIN, ANALOG); // PINのモード設定 // https://lang-ship.com/blog/work/m5stickc-io/ } void loop() { - Serial.printf("%04d\n", analogRead(PIN) ); // 暗 0 〜 4095 明 - delay(1000); + int val = analogRead(PIN); + #ifdef USE_DISPLAY + M5.Lcd.fillScreen( CYAN ); + M5.Lcd.setCursor(30, 34, 4); M5.Lcd.setTextSize(2); + M5.Lcd.setTextColor( WHITE, BLUE ); + M5.Lcd.printf(" %4d \n CdS ", val); + #endif + + Serial.printf("%04d\n", val ); // 暗 0 〜 4095 明 + delay(300); + } + diff --git a/SampleSrc/led01.ino b/SampleSrc/led01.ino index 4149c43..068b64d 100644 --- a/SampleSrc/led01.ino +++ b/SampleSrc/led01.ino @@ -1,15 +1,24 @@ -int PIN = 10; // 赤色LED G10 -//int PIN = 9; // Ir LED (カメラには映りますが、肉眼では見えません) G9 -// その他、G0 (0) , G25 (25), G26 (26) がつかえます。 -// https://lang-ship.com/blog/work/m5stickc-io/ - -void setup() { - pinMode(PIN, OUTPUT); // PINのモード設定 -} - -void loop() { - digitalWrite(PIN, HIGH); // HIGH = 1 - delay(1000); - digitalWrite(PIN, LOW); // LOW = 0 - delay(500); -} \ No newline at end of file +int PIN = 10; // 赤色LED G10 +int PIN2 = 26; // 外部LED G0 +//int PIN3 = 9; // Ir LED (カメラには映りますが、肉眼では見えません) G9 +// G0 (0) , G25 (25), G26 (26) がつかえます。 +// https://lang-ship.com/blog/work/m5stickc-io/ + +void setup() { + Serial.begin(115200); + pinMode(PIN, OUTPUT); // PINのモード設定 + pinMode(PIN2, OUTPUT); // PIN2のモード設定 +} + +void loop() { + digitalWrite(PIN, HIGH); // HIGH = 1 + digitalWrite(PIN2, HIGH); // HIGH = 1 + Serial.println("HIGH"); + delay(1000); + digitalWrite(PIN, LOW); // LOW = 0 + digitalWrite(PIN2, LOW); // LOW = 0 + Serial.println("LOW"); + delay(500); +} + + diff --git a/SampleSrc/mqtt01pub.ino b/SampleSrc/mqtt01pub.ino index 93e1b0a..eeb2724 100644 --- a/SampleSrc/mqtt01pub.ino +++ b/SampleSrc/mqtt01pub.ino @@ -76,3 +76,4 @@ } +