Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
takenorioshima committed Oct 16, 2021
0 parents commit fbbd7b0
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
64 changes: 64 additions & 0 deletions MidiBulb.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include <MIDI.h>
#include <SoftwareSerial.h>

SoftwareSerial softSerial(2,3);
MIDI_CREATE_INSTANCE(SoftwareSerial, softSerial, midiA);

const int bulbPinA = 4;
const int bulbPinB = 5;
const int bulbPinC = 6;
const int bulbPinD = 7;
const int statusLed = 13;

void handleNoteOn(byte channel, byte pitch, byte velocity)
{
switch( pitch % 4 ){
case 0:
digitalWrite(bulbPinA, HIGH);
break;
case 1:
digitalWrite(bulbPinB, HIGH);
break;
case 2:
digitalWrite(bulbPinC, HIGH);
break;
case 3:
digitalWrite(bulbPinD, HIGH);
}
digitalWrite(statusLed, HIGH);
}

void handleNoteOff(byte channel, byte pitch, byte velocity)
{
switch( pitch % 4 ){
case 0:
digitalWrite(bulbPinA, LOW);
break;
case 1:
digitalWrite(bulbPinB, LOW);
break;
case 2:
digitalWrite(bulbPinC, LOW);
break;
case 3:
digitalWrite(bulbPinD, LOW);
}
digitalWrite(statusLed, LOW);
}

void setup()
{
midiA.setHandleNoteOn(handleNoteOn);
midiA.setHandleNoteOff(handleNoteOff);
midiA.begin(MIDI_CHANNEL_OMNI);

pinMode(bulbPinA, OUTPUT);
pinMode(bulbPinB, OUTPUT);
pinMode(bulbPinC, OUTPUT);
pinMode(bulbPinD, OUTPUT);
}

void loop()
{
midiA.read();
}

0 comments on commit fbbd7b0

Please sign in to comment.