#include <M5Unified.h>
#include <Arduino.h>
#define IR_ANALOG_PIN 8
#define IR_DIGITAL_PIN 9
void setup()
{
M5.begin();
M5.Display.setFont(&fonts::FreeMonoBold12pt7b);
pinMode(IR_ANALOG_PIN, INPUT);
pinMode(IR_DIGITAL_PIN, INPUT);
}
void loop()
{
int analog = analogRead(IR_ANALOG_PIN);
int digital = digitalRead(IR_DIGITAL_PIN);
M5.Display.clear();
M5.Display.setCursor(20, 40);
M5.Display.printf("analog: %d", analog);
M5.Display.setCursor(20, 80);
M5.Display.printf("digital: %d", digital);
Serial.printf("analog: %d\r\n", analog);
Serial.printf("digital: %d\r\n", digital);
delay(1000);
}
For CoreS3, press and hold the reset button (for about 2 seconds) until the internal green LED lights up, and then release it. This indicates the device is in download mode and ready for programming.
Read the digital and analog signals output by the Unit Reflective IR and display them.