rewrote AltPinSerial to use SoftwareSerial
This commit is contained in:
parent
9d43a8370e
commit
1e14162bf4
|
|
@ -1,27 +1,30 @@
|
|||
#include <SoftwareSerial.h>
|
||||
#include <MIDI.h>
|
||||
#include "altPinSerialMIDI.h"
|
||||
|
||||
// Simple tutorial on how to receive and send MIDI messages.
|
||||
// Here, when receiving any message on channel 4, the Arduino
|
||||
// will blink a led and play back a note for 1 second.
|
||||
|
||||
AltSerialMIDI<HardwareSerial> serialMIDI(Serial1, 18, 19);
|
||||
MIDI_NAMESPACE::MidiInterface<AltSerialMIDI<HardwareSerial>> MIDI((AltSerialMIDI<HardwareSerial>&)serialMIDI);
|
||||
int rxPin = 18;
|
||||
int txPin = 19;
|
||||
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
|
||||
MIDI_NAMESPACE::SerialMIDI<SoftwareSerial> serialMIDI(mySerial);
|
||||
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<HardwareSerial>> MIDI((MIDI_NAMESPACE::SerialMIDI<HardwareSerial>&)serialMIDI);
|
||||
|
||||
void setup()
|
||||
{
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
MIDI.begin(4); // Launch MIDI and listen to channel 4
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
MIDI.begin(4); // Launch MIDI and listen to channel 4
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (MIDI.read()) // If we have received a message
|
||||
{
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
MIDI.sendNoteOn(42, 127, 1); // Send a Note (pitch 42, velo 127 on channel 1)
|
||||
delay(1000); // Wait for a second
|
||||
MIDI.sendNoteOff(42, 0, 1); // Stop the note
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
}
|
||||
if (MIDI.read()) // If we have received a message
|
||||
{
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
MIDI.sendNoteOn(42, 127, 1); // Send a Note (pitch 42, velo 127 on channel 1)
|
||||
delay(1000); // Wait for a second
|
||||
MIDI.sendNoteOff(42, 0, 1); // Stop the note
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue