/*
* 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