脱線気味ですが
実際のところ
platformio.ini
[env:teensy40] platform = teensy board = teensy40 framework = arduino upload_protocol = teensy-gui build_flags = -DTEENSY_OPT_FASTER -DUSB_SERIAL_HID
スクリプト
公式サンプルが若干使いづらい
#include <Arduino.h> const int buttonPin = 2; // Teensy 4.0のボタンピン(モデルによって異なる場合があります) void setup() { pinMode(buttonPin, INPUT_PULLUP); Mouse.begin(); } void loop() { if (digitalRead(buttonPin) == LOW) { // ボタンが押されている場合 // 円を描くようにマウスを動かす for (int i = 0; i < 360; i += 5) { float rad = i * PI / 180.0; int x = round(cos(rad) * 5); int y = round(sin(rad) * 5); Mouse.move(x, y); delay(10); // ボタンが離されたらループを抜ける if (digitalRead(buttonPin) == HIGH) { break; } } delay(10); // 短い遅延を入れてCPU使用率を下げる } }
これでリモートワークも安心(歪んだ見解