pin 1 conflict using LCD and MIDI library

i’m building a simple synth-thingy, that should read MIDI messages, and also output stuff on an LCD screen, but things have gotten weird.
Due to other things going on in the program, i can only utilize pins 1,4,5,7,8 and A0 to drive the LCD creen (workes fine on it’s own without any midi).
at the same time, the atmega should be able to read midi data from pin 0, and since i do not output any midi data, there should not be any compatibility problem.

this is the sketch i use to reproduce the problem

#include <LiquidCrystal.h>
#include <MIDI.h>

LiquidCrystal lcd(1,4,5,7,8,A0);

void setup() 

void loop()

note that the code works as expected if you comment out the " MIDI.begin();" call.

to be extra sure that no MIDI data was outputted, i forced the programmer to not compile the code necessary by modifying the library’s MIDI.h file…

#define COMPILE_MIDI_IN         1           // Set this setting to 1 to use the MIDI input.
#define COMPILE_MIDI_OUT        0           // Set this setting to 1 to use the MIDI output. 
#define COMPILE_MIDI_THRU       0           // Set this setting to 1 to use the MIDI Soft Thru feature
                                            // Please note that the Thru will work only when both COMPILE_MIDI_IN and COMPILE_MIDI_OUT set to 1.

but, the problem still remained.

after further tests, i tried to comment out the line


inside the " MIDI_Class::begin " function, and after re-uploading the program to the chip, it worked as expected.
obviously though this is not a solution, as it probably renders the MIDI library useless.

another thing i tried was to use a pair of headphones to “hear” if any data was being transmitted on line 1 (this is the closest to an oscilloscope as i can get).

without the MIDI.begin() function i hear many “clicks” , meaning that data is sent to the LCD screen, and everything works fine.

with the MIDI.Begin() function in the setup, the line is instead completely silent, meaning that it is held either HIGH or LOW all of the time, and thus no data can be sent to the screen on that line.

So basically pin 1 is held HIGH all of the time, and the LCD library is not able to access this pin and change it’s state, even though it should not be used by the MIDI library… aaand i have no clue of how to solve this problem.
also, unfortunately i cannot change from pin1 to something else.

so… does know why the LCD library cannot change pin1’s state, and if there is any solution to this problem?

if there is any solution to this problem?

Yes, don’t use pin 1 with the LCD. It is used for serial communication which is what the MIDI output uses. Use another pin instead.

hi, thanks for answering... unfortunately i cannot change pin as it would create way more problems that it would solve, as i'd have to change many aspects of my program, redesign a few PCBs, and re-purchase them... i'd very gladly avoid having to do this (unless there is [u]absolutely[/u] no other solution)...

what i'm hoping is that, since i only use pin 0 (RX) to receive messages, and i do not have to use pin 1 to output anything, i could in a way or another disable the serial communication on that pin, and just use it as any other normal digital output. would it be possible?

unless there is absolutely no other solution

Two choices - change the pin or quit using Serial (that includes MIDI).

Why didn't you test the software before designing custom PCBs?

i was very short on time, and since i haven't got a huge budget, i was forced to use a pcb service that takes a lot of time...and the quicker i ordered the pcbs the quicker they would have arrived...

i guess this will teach me a good lesson for the future...

I was having the exact same issue, and was equally disappointed when I found this post, but with a little persistence I eventually found the solution is as simple as:

Disable TX:

UCSR0B &= ~B00001000

Enable TX:

UCSR0B |= B00001000 is a real shame that you were basically told to throw away all the of time and money you had invested in your project so far and go back to the drawing board!! :(