実装で参考になりそうなもの
関数一覧(日本語)
http://www.musashinodenpa.com/arduino/ref/index.php
キーボード関数について
https://www.arduino.cc/reference/en/language/functions/usb/keyboard/
文字以外のキー入力をする場合
https://garretlab.web.fc2.com/arduino_reference/language/functions/usb/keyboard/keyboard_modifiers.html
マウス関数について
https://www.arduino.cc/reference/en/language/functions/usb/mouse/
加速度センサをキーボード化する
https://fieldwalking.jp/blog/arduino-kasokudo/
加速度センサをマウス化する
https://qiita.com/intel_outside/items/37c5ff45622aba352dfa
GPIOについて
https://synapse.kyoto/glossary/gpio/page001.html
https://www.switch-science.com/catalog/1293/
トラブルシューティング
Keyboard.hがインクルードできない
ボードをArduino Leonardoに設定する
https://teratail.com/questions/146817
Arduino Leonardoに書き込めない
完全にキーボードとして認識されてしまっている
Arduino Leonardのリセットボタンを押して、書き込む
https://qiita.com/enkatsu/items/107b9308889117076fac
MacとArduinoがうまく接続できない / 書き込みエラーが出てしまう
USBでまわりエラーが出ているのかも
SMCリセットを試してみよう
https://support.apple.com/ja-jp/HT201295
PRAMリセットも?
https://support.apple.com/ja-jp/HT204063
入力に即応したい
割り込み処理を使う
外部割り込み
https://novicengineering.com/arduinoの割り込み機能を使ってみる/
タイマー割り込み
http://zattouka.net/GarageHouse/micon/Arduino/TIMERtoLED/TIMERtoLED.htm
並列処理がしたい
Arduinoはマルチタスクができないが・・・
http://mukujii.sakura.ne.jp/arduino1.html
https://oshiete.goo.ne.jp/qa/9747139.html
段ボール工作の方法
https://www.ohmsha.co.jp/book/9784274222894/
https://www.oreilly.co.jp/books/9784873119649/
1. タクトスイッチの面積を10cm x 10cmに拡張し、端を押しても反応するようにする
code:beep.js
void setup() {
pinMode(2,INPUT);//D2にスイッチをつなぐ
pinMode(5, OUTPUT);//D5にブザーをつなぐ
}
void loop() {
int sw = digitalRead(2);
if(sw==HIGH){
tone(5, 261,500);
}else{
}
}
2. 加速度センサでデコピンの強さを計測する
code:deco.js
//Gravity Acceleration
#include "LIS3DHTR.h"
#ifdef SOFTWAREWIRE
#include <SoftwareWire.h>
SoftwareWire myWire(3, 2);
LIS3DHTR<SoftwareWire> LIS; //Software I2C
#define WIRE myWire
#else
#include <Wire.h>
LIS3DHTR<TwoWire> LIS; //Hardware I2C
#define WIRE Wire
#endif
void setup() {
Serial.begin(9600);
while (!Serial) {};
LIS.begin(WIRE, 0x19); //IIC init
delay(100);
LIS.setOutputDataRate(LIS3DHTR_DATARATE_50HZ);
}
void loop() {
if (!LIS) {
Serial.println("LIS3DHTR didn't connect.");
while (1);
return;
}
//3 axis
Serial.println(abs(LIS.getAccelerationX()*LIS.getAccelerationY()*LIS.getAccelerationZ()));
delay(50);
}
3. ロータリーエンコーダを360度回転可能にする
code:rota.js
void setup() {
Serial.begin(9600);
pinMode(A0, INPUT);
}
void loop() {
int n = analogRead(A0);
Serial.println(n);
delay(50);
}