PLUS Module Encoder Module with MEGA328P 500mAh Battery

via M5Stack
$22.28
SKU M5-M019
Description

PLUS is a enhanced M5 module comes with Lipo battery(500mAh), gear potentiometer, IR transmitter, extend PORT B(GPIO Port), PORT C(UART Port) from M5 core and a Microphone soldering pad. Powered with MEGA328, it could be a great upgrade of the hardwre resources by adding up PLUS to your work.

Communication Protocol: IIC (0x62).

Product Features

  • 500mAh Battery
  • Programmable gear potentiometer
  • IR transmitter
  • PORT B & PORT C

Kit includes

  • 1x M5Stack PLUS Module
Documents
Learn

Example

Arduino IDE

Code below plus_read_encoder.ino is incomplete. To get the complete code, please click here.*

/*
* Read data from the gear potentiometer
* Send infrared light
*/
#include <Arduino.h>
#include <M5Stack.h>

#define IrPin 13
#define PLUS_ADDR 0x62

// declaration
int32_t number = 0;
uint8_t press = 0;

// initialization
M5.begin(true, false, false);
Wire.begin();
ledcSetup(1, 38000, 10); ledcAttachPin(IrPin, 1);// IR Pin setting

// read data
Wire.requestFrom(PLUS_ADDR, 2);
while(Wire.available()) {
    int8_t encode = Wire.read();
    uint8_t press_n = Wire.read();
    number += encode;
    if(press_n == 0xff) {
        press = 0;//encoder was pressed
    }
    else {
        press = 1;//encoder was releaed
    }
}
More information

Schematic