Skip to content

Instantly share code, notes, and snippets.

View hollyhockberry's full-sized avatar

hollyhockberry

View GitHub Profile
@hollyhockberry
hollyhockberry / main.cpp
Created September 8, 2022 11:47
RFID Unit2 with M5Unified
// Connect RFID Unit2 to Port.A
#include <M5Unified.h>
#include "MFRC522_I2C.h" // https://github.com/m5stack/M5Stack/tree/master/examples/Unit/RFID_RC522
static MFRC522 mfrc522_(0x28);
static String data = "";
void setup() {
M5.begin();
@hollyhockberry
hollyhockberry / accel.ino
Last active August 10, 2022 07:54
Sample: plot accel data
#include <M5StickC.h>
float _x, _y, _z;
void setup() {
M5.begin();
M5.Imu.Init();
M5.IMU.getAccelData(&_x, &_y, &_z);
}
@hollyhockberry
hollyhockberry / sender.cpp
Created August 6, 2022 00:26
Sample: ESP-NOW broadcast
// ESP-NOW broadcast sender
#include <Arduino.h>
#include <esp_now.h>
#include <WiFi.h>
// タクトスイッチのピン
constexpr uint8_t SW_PIN = G39;
constexpr uint8_t CHANNEL = 1;
constexpr uint8_t BROADCAST[] = {
@hollyhockberry
hollyhockberry / unit_ultrasonic_i2c.ino
Created June 21, 2022 11:36
M5Stack: UNIT ULTRASONIC-I2C
#include <Arduino.h>
#include <Wire.h>
float read_distance() {
Wire.beginTransmission(0x57);
Wire.write(0x01);
Wire.endTransmission();
::delay(50);
if (Wire.requestFrom(0x57, 3) != 3) {
return -1;
@hollyhockberry
hollyhockberry / main.cpp
Last active May 6, 2022 14:21
M5Unified: Click on the edge of the iPad screen
#include <M5Unified.h>
#include <BleMouse.h> // https://github.com/T-vK/ESP32-BLE-Mouse
BleMouse mouse;
void move(bool left) {
const uint8_t dx = 100 * (left ? -1 : 1);
for (auto i = 0; i < 10; ++i) {
mouse.move(dx, 0);
::delay(1);
@hollyhockberry
hollyhockberry / main.cpp
Created March 8, 2022 10:50
M5ATOM: SG90 Servo
// SG90 brown -> GND
// red -> 5v
// orange -> G26
#include <M5Atom.h>
void setDegree(double deg) {
Serial.printf("Deg: %f\r\n", deg);
auto v = deg * (2.4 - 0.5) / 180.0 + 0.5;
v /= 20.0;
@hollyhockberry
hollyhockberry / main.cpp
Last active January 28, 2022 18:05
M5Atom: LGFX: test for Waveshare 1.28inch Round LCD
#define LGFX_USE_V1
#include <SPIFFS.h>
#include <LovyanGFX.hpp>
constexpr static char PNG_FILE[] = "/picture.png";
class LGFX : public lgfx::LGFX_Device {
lgfx::Panel_GC9A01 _panel_instance;
lgfx::Bus_SPI _bus_instance;
lgfx::Light_PWM _light_instance;
@hollyhockberry
hollyhockberry / main.cpp
Created January 11, 2022 10:05
SCD30 sample
#include <Arduino.h>
#include <SparkFun_SCD30_Arduino_Library.h>
SCD30 airSensor;
void setup() {
Serial.begin(115200);
Wire.begin(1, 0);
if (airSensor.begin() == false) {
ESP_LOGE("", "Failed to begin SCD30.");
@hollyhockberry
hollyhockberry / main.cpp
Created October 25, 2021 12:30
FADER Unit and IR Unit on single task
#include <Arduino.h>
#include <IRsend.h>
static IRsend irsend(26);
static constexpr int input_pin = 13;
void setup() {
irsend.begin();
}
@hollyhockberry
hollyhockberry / main.cpp
Created October 25, 2021 12:24
FADER Unit and IR Unit with M5Core2 AWS
#include <Arduino.h>
#include <IRsend.h>
volatile SemaphoreHandle_t xMutex = NULL;
int targetVolume = 0;
int currentVolume = targetVolume;
constexpr int input_pin = 13;
void task_main(void* arg) {