Skip to content

Commit 1e14162

Browse files
authored
rewrote AltPinSerial to use SoftwareSerial
1 parent 9d43a83 commit 1e14162

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed
Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
1+
#include <SoftwareSerial.h>
12
#include <MIDI.h>
2-
#include "altPinSerialMIDI.h"
33

44
// Simple tutorial on how to receive and send MIDI messages.
55
// Here, when receiving any message on channel 4, the Arduino
66
// will blink a led and play back a note for 1 second.
77

8-
AltSerialMIDI<HardwareSerial> serialMIDI(Serial1, 18, 19);
9-
MIDI_NAMESPACE::MidiInterface<AltSerialMIDI<HardwareSerial>> MIDI((AltSerialMIDI<HardwareSerial>&)serialMIDI);
8+
int rxPin = 18;
9+
int txPin = 19;
10+
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
11+
MIDI_NAMESPACE::SerialMIDI<SoftwareSerial> serialMIDI(mySerial);
12+
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<HardwareSerial>> MIDI((MIDI_NAMESPACE::SerialMIDI<HardwareSerial>&)serialMIDI);
1013

1114
void setup()
1215
{
13-
pinMode(LED_BUILTIN, OUTPUT);
14-
MIDI.begin(4); // Launch MIDI and listen to channel 4
16+
pinMode(LED_BUILTIN, OUTPUT);
17+
MIDI.begin(4); // Launch MIDI and listen to channel 4
1518
}
1619

1720
void loop()
1821
{
19-
if (MIDI.read()) // If we have received a message
20-
{
21-
digitalWrite(LED_BUILTIN, HIGH);
22-
MIDI.sendNoteOn(42, 127, 1); // Send a Note (pitch 42, velo 127 on channel 1)
23-
delay(1000); // Wait for a second
24-
MIDI.sendNoteOff(42, 0, 1); // Stop the note
25-
digitalWrite(LED_BUILTIN, LOW);
26-
}
22+
if (MIDI.read()) // If we have received a message
23+
{
24+
digitalWrite(LED_BUILTIN, HIGH);
25+
MIDI.sendNoteOn(42, 127, 1); // Send a Note (pitch 42, velo 127 on channel 1)
26+
delay(1000); // Wait for a second
27+
MIDI.sendNoteOff(42, 0, 1); // Stop the note
28+
digitalWrite(LED_BUILTIN, LOW);
29+
}
2730
}

0 commit comments

Comments
 (0)