Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. include MIDI.h>
  2. MIDI_CREATE_DEFAULT_INSTANCE();
  3. byte anodes[5] = {30, 32, 34, 36,38};
  4. byte cathodes[5] = {31, 33, 35, 37,39};
  5. byte data1 = 0;
  6.  
  7. void setPinTo5V(byte pin) //set a pin given to this function to a 5V voltage source
  8. {
  9. pinMode(pin, OUTPUT);
  10. digitalWrite(pin, HIGH);
  11. }
  12.  
  13. void setPinToGND(byte pin) //set a pin given to this function to a GROUND (GND pin)
  14. {
  15. pinMode(pin, OUTPUT);
  16. digitalWrite(pin, LOW);
  17. }
  18.  
  19. void loop() {
  20. MIDI.read();
  21. }
  22.  
  23. void MyHandleNoteOn(byte channel, byte pitch, byte velocity)
  24. {
  25. data1 = MIDI.getData1();
  26. if (data1==48){//C3
  27. setPinTo5V(anodes[0]);//set pin 30 to 5V
  28. setPinToGND(cathodes[0]);//set pin 31 to GND
  29. delay(1); //do nothing for 1 ms
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement