
Arduino Quick Start


A_PIN and D_PIN definitions in the program according to the actual circuit connections. The program below uses G36(A_PIN) and G26(D_PIN).#include <M5Unified.h>
#include <M5GFX.h>
#define A_PIN 36
#define D_PIN 26
M5Canvas img(&M5.Lcd);
void setup()
{
M5.begin();
M5.Power.begin();
img.setColorDepth(8);
img.createSprite(320, 240);
img.setTextSize(2);
// Set pin as input mode
pinMode(A_PIN, INPUT);
pinMode(D_PIN, INPUT);
}
void loop()
{
static uint16_t digitalRead_value = 0, analogRead_value = 0;
analogRead_value = analogRead(A_PIN);
digitalRead_value = digitalRead(D_PIN);
img.fillRect(0, 0, 320, 240, 0x00);
img.drawCenterString("Unit Light Test", 160, 5);
img.setCursor(90, 30);
img.printf("Analog:%d\n", analogRead_value);
img.setCursor(90, 50);
img.printf("Digital:%d\n", digitalRead_value);
img.pushSprite(0, 0);
delay(10);
}
Analog value and switching of the Digital state.