English
English
简体中文
日本語
pdf-icon

Arduino Quick Start

2. Devices & Examples

5. Extensions

6. Applications

Stamp C6LoRa EXT IO

Stamp C6LoRa integrates the PI4IOE5V6408 IO expansion chip internally. In addition to controlling the LoRa module's transceiver circuit and signal amplifier enable, it also exposes the EXT_P0 ~ P4 interfaces to provide additional IO resources.

Example Code

Compilation Requirements

  • M5Stack Board Manager version >= 3.2.6
  • Board Option = M5StampC6LoRa
  • M5Unified library version >= 0.2.13
  • M5GFX library version >= 0.2.19

Output

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#include <Arduino.h>
#include <M5Unified.h>
#include "utility/PI4IOE5V6408_Class.hpp"

m5::I2C_Class i2c_bus_0;
m5::PI4IOE5V6408_Class ioe(0x43, 400000, &i2c_bus_0);

void setup()
{
    Serial.begin(115200);
    delay(300);
    Serial.println("PI4IOE5V6408 Output Example");

    if (!i2c_bus_0.begin(I2C_NUM_0, 10, 8)) {
        Serial.println("I2C init failed");
        while (true) delay(1000);
    }
    if (!ioe.begin()) {
        Serial.println("IOE init failed");
        while (true) delay(1000);
    }

    for (int i = 0; i < 5; i++) {
        ioe.setDirection(i, true);      // output
        ioe.setHighImpedance(i, false); // disable high-impedance so pin can actually drive
        ioe.digitalWrite(i, false);     // default low
    }
}

void loop()
{
    static bool state = false;
    state = !state;

    for (int i = 0; i < 5; i++) {
        ioe.digitalWrite(i, state);
        Serial.printf("[EXT_P%d] %d  ", i, (int)state);
    }
    Serial.println();
    delay(1000);
}

Input

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#include <Arduino.h>
#include <M5Unified.h>
#include "utility/PI4IOE5V6408_Class.hpp"

m5::I2C_Class i2c_bus_0;
m5::PI4IOE5V6408_Class ioe(0x43, 400000, &i2c_bus_0);

void setup()
{
    Serial.begin(115200);
    delay(300);
    Serial.println("PI4IOE5V6408 Input Example");

    if (!i2c_bus_0.begin(I2C_NUM_0, 10, 8)) {
        Serial.println("I2C init failed");
        while (true) delay(1000);
    }
    if (!ioe.begin()) {
        Serial.println("IOE init failed");
        while (true) delay(1000);
    }

    for (int i = 0; i < 5; i++) {
        ioe.setDirection(i, false);   // input
        ioe.enablePull(i, true);      // enable internal pull resistor
        ioe.setPullMode(i, true);     // pull-up (true=up, false=down)
    }
}

void loop()
{
    for (int i = 0; i < 5; i++) {
        Serial.printf("[EXT_P%d] %d  ", i, (int)ioe.digitalRead(i));
    }
    Serial.println();

    delay(1000);
}
On This Page