c_cpp LCD MIDI Monitor v2.0

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp LCD MIDI Monitor v2.0相关的知识,希望对你有一定的参考价值。

/* 
 * LCD MIDI Monitor v2.0
 */  

#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins 
LiquidCrystal lcd(2,3,4,5,6,7);

byte incomingByte;  // Stock the first received byte
byte note;          // Stock the second received byte
byte velocity;      // Stock the third received byte
byte message;       // Message type
byte channel;       // MIDI channel

void setup(){
  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  //set midi baud rate
  Serial.begin(31250);
  
  //Home message
  lcd.setCursor(0,0); // First LCD Row
  lcd.print(" Veitch Digital ");
  lcd.setCursor(0,1); // Second LCD Row
  lcd.print("TimeMachine v2.0");
  
  delay(3000); // Wait 3 seconds
  lcd.clear(); // Clear the display
  lcd.setCursor(0,0); // First LCD Row
  lcd.print("Waiting..."); // Print "waiting..." message
}

void loop() {

  if (Serial.available() > 0) {
    
    // read the incoming byte:
    incomingByte = Serial.read();
    message = ( incomingByte >> 4 ) - B1000;  //convert the first byte to find the message type
    channel = ( incomingByte & B1111 ) + 1; //convert the first byte to find the MIDI Channel
    
    if( incomingByte <= 240 ){ // is it a message system?
      lcd.setCursor(9,0);
      lcd.print("Ch :   ");
      lcd.setCursor(14,0);
      lcd.print(channel,DEC);
      
      if ( message == 4 ){ //is it a message Program Change?
        lcd.setCursor(0,0);
        lcd.print("PrgCh    ");
        note = Serial.read();
        lcd.setCursor(0,1);
        lcd.print("ProgNum:        ");
        lcd.setCursor(10,1);
        lcd.print(note+1,DEC);
      }
      
    } // end incomingByte
  } // end serial.available
} //end loop

以上是关于c_cpp LCD MIDI Monitor v2.0的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp Dilicktal_MIDI v2_0

c_cpp Midi程序变更示例

c_cpp MIDI控制器由jardous

c_cpp ofApp.cpp用于MIDI时间码

c_cpp ofApp.h用于MIDI TIMECODE

c_cpp Dilicktal_MIDI v1_0