This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// プロダクトデザイン応用実習サンプルコード - Arduino Leonardoをワンボタンキーボードとして使う | |
// 参考:修飾キーと特殊キー https://garretlab.web.fc2.com/arduino_reference/language/functions/usb/keyboard/keyboard_modifiers.html | |
// Arduinoをキーボードにするライブラリ「Keyboard」を使いますという宣言 | |
#include "Keyboard.h" | |
void setup() | |
{ | |
Keyboard.begin(); // Keyboardライブラリを使うためのおまじない | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// プロダクトデザイン応用実習サンプルコード - 可変抵抗と値を読み取りBLE経由でMIDIを送る | |
// USB経由でMIDIを扱うライブラリ「BLE-MIDI」を使いますという宣言 | |
#include <BLEMIDI_Transport.h> | |
#include <hardware/BLEMIDI_ESP32.h> | |
BLEMIDI_CREATE_INSTANCE("KNOB", MIDI); // BLE-MIDIデバイスに「KNOB」という名前をつける | |
int exCC = 0; // 同じ値を送り続けないためにループの最後でCCの値を格納しておくための変数 | |
void setup() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// プロダクトデザイン応用実習サンプルコード - Bluetooth経由でMIDIを受けてサーボを動かす | |
#include <ESP32Servo.h> //ESP32でサーボを扱うライブライを使いますという宣言 | |
Servo myservo; // 扱うサーボにmyservoと名前をつける | |
// BLE経由でMIDIを扱うライブラリ「BLE-MIDI」を使いますという宣言 | |
#include <BLEMIDI_Transport.h> | |
#include <hardware/BLEMIDI_ESP32.h> | |
BLEMIDI_CREATE_DEFAULT_INSTANCE() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// プロダクトデザイン応用実習サンプルコード - Bluetooth経由で単純なMIDI(ノートオンオフ)を受ける | |
// 参考 : switch case文 http://www.musashinodenpa.com/arduino/ref/index.php?f=0&pos=126 | |
// BLE経由でMIDIを扱うライブラリ「BLE-MIDI」を使いますという宣言 | |
#include <BLEMIDI_Transport.h> | |
#include <hardware/BLEMIDI_ESP32.h> | |
BLEMIDI_CREATE_DEFAULT_INSTANCE() | |
void setup() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// プロダクトデザイン応用実習サンプルコード - 可変抵抗と値を読み取りUSB経由でMIDI(コントロールチェンジ)を送る | |
// USB経由でMIDIを扱うライブラリ「USB-MIDI」を使いますという宣言 | |
#include <USB-MIDI.h> | |
USBMIDI_CREATE_DEFAULT_INSTANCE(); | |
int exCC = 0; // 同じ値のMIDIを送り続けないためにループの最後でCCの値を格納しておくための変数 | |
void setup() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// プロダクトデザイン応用実習サンプルコード - USB経由でMIDI(コントロールチェンジ)を受けてサーボを動かす | |
#include <Servo.h> //サーボを扱うライブライを使いますという宣言 | |
Servo myservo; // 扱うサーボにmyservoと名前をつける | |
// USB経由でMIDIを扱うライブラリ「USB-MIDI」を使いますという宣言 | |
#include <USB-MIDI.h> | |
USBMIDI_CREATE_DEFAULT_INSTANCE(); | |
void setup() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// プロダクトデザイン応用実習サンプルコード - USB経由で単純なMIDI(ノートオンオフ)を受ける | |
// 参考 : switch case文 http://www.musashinodenpa.com/arduino/ref/index.php?f=0&pos=126 | |
// USB経由でMIDIを扱うライブラリ「USB-MIDI」を使いますという宣言 | |
#include <USB-MIDI.h> | |
USBMIDI_CREATE_DEFAULT_INSTANCE(); | |
void setup() | |
{ | |
// MIDIの初期設定と受け付けるチャンネルの指定 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// プロダクトデザイン応用実習サンプルコード - USB経由で単純なMIDI(ノートオンオフ)を送る | |
// USB経由でMIDIを扱うライブラリ「USB-MIDI」を使いますという宣言 | |
#include <USB-MIDI.h> | |
USBMIDI_CREATE_DEFAULT_INSTANCE(); | |
void setup() | |
{ | |
// MIDIの初期設定と受け付けるチャンネルの指定 | |
MIDI.begin(1); // チャンネルが1のときのみ受け付ける(このコードでは送るだけなのでなんでもいい) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//プロダクトデザイン応用実習サンプルコード - モーメンタリスイッチをオルタネイトスイッチとして扱い、さらにサーボを動かす | |
#include <Servo.h> //ライブラリを使いますという宣言 | |
Servo myservo; // サーボにmyservoと名前をつける | |
bool flag = false; //直前のセンサーの状態を記録しておくための変数 | |
int threshold = 500; //閾値 | |
int kakudo = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//プロダクトデザイン応用実習サンプルコード - オルタネイト動作でLEDをふんわり点灯/消灯させるサンプルコード | |
int led = 13; | |
bool flag = false; //直前のセンサーの状態を記録しておくための変数 | |
int threshold = 500; //閾値 | |
void setup() { | |
Serial.begin(9600); //シリアルモニタを使いますという宣言 | |
pinMode(led, OUTPUT); | |
} |