Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include MIDI.h>
- MIDI_CREATE_DEFAULT_INSTANCE();
- byte anodes[5] = {30, 32, 34, 36,38};
- byte cathodes[5] = {31, 33, 35, 37,39};
- byte data1 = 0;
- void setPinTo5V(byte pin) //set a pin given to this function to a 5V voltage source
- {
- pinMode(pin, OUTPUT);
- digitalWrite(pin, HIGH);
- }
- void setPinToGND(byte pin) //set a pin given to this function to a GROUND (GND pin)
- {
- pinMode(pin, OUTPUT);
- digitalWrite(pin, LOW);
- }
- void loop() {
- MIDI.read();
- }
- void MyHandleNoteOn(byte channel, byte pitch, byte velocity)
- {
- data1 = MIDI.getData1();
- if (data1==48){//C3
- setPinTo5V(anodes[0]);//set pin 30 to 5V
- setPinToGND(cathodes[0]);//set pin 31 to GND
- delay(1); //do nothing for 1 ms
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement