
Arduino Quick Start
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.
#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);
}
#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);
}