Go Down

Topic: LCD 16x2 with Max/MSP - problems with typing on bottom line. (Read 1 time) previous topic - next topic

paleorama

Hi,
I'm a new user in here - and pretty new to the arduino environment. I am pretty used to building modules in Max/MSP and I want this 16x2 LCD display to show me what I am doing in Max. It all works fine so far, the LCD and the arduino is working and the serial object in max is succesfully converting symbols to ASCII and sending via the serial port.
But I am having trouble with breaking the line and sending symbols to the second line on the display - the bottom line.

I am using the following code on the chip:

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup(){
    // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // initialize the serial communications:
  Serial.begin(38400);
}

void loop()
{
  // when characters arrive over the serial port...
  if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(10);
    // clear the screen
    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0) {
      // display each character to the LCD
      lcd.write(Serial.read());
    }
  }
}


paleorama

My max patch looks like this, in all its simplicity:

PaulS

Serial data transmission is relatively slow. You are clearing the screen, reading everything in the buffer, and starting loop over again. It is very unlikely that more than 16 characters will arrive on the serial port, while you are clearing the screen. So, there is never anything to wrap onto the second line.

keepsound

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
const int numRows = 2;
const int numCols = 16;

void setup(){
    // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // initialize the serial communications:
  Serial.begin(38400);
}

void loop()
{
 if (Serial.available() > 0) {
   
    delay(10);
   
    lcd.clear();

    lcd.setCursor (0,0);

    for(int i = 0; Serial.available() > 0; i++){
      if(i == 16){
        lcd.setCursor(0,1);
      }
      lcd.write(Serial.read());
    }
 }
 delay(1000);
}
     
     
 

keepsound

This is a final standalone project, compile it, add the java folder with the autobot.class and .java file inside and connetc your Arduino with the LCD Keypad Shield.
Be sure to use the correct interface pins LiquidCrystal lcd(8, 9, 4, 5, 6, 7)...this is the set of the Leonardo.

keepsound

Divided in two parts due the 9000 caracter limitation
1st part

<pre><code>
----------begin_max5_patcher----------
6913.3oc6cs0iqiaj9497qPqSda6SOh2kRv7vjKKvhMIH6j.rXwLCFn1Vc25
L1VdkjOWlf7eeoXQYS4qjzhsUOwAS59Tx1sYUrXwhU8UE+Gu6tIOV9475IQ+
lnuK5t69Gu6t6TOp8A2oouaxhrOOcdVs5sMYQdcc1y4StGdsl7O2ndd15lxG
Kahlm2D8g0KVE07Rdzz0U0kUQEKqKlkqdRc9zxkyhdb957npxOEk8TSdUzpJ
4e0hkOqdKMYOF835llxkceIyKVJ+XqWp9lv5Gtb8hhkxusZyGtJqY5Kx+P+X
U9zFfsRvwOfY2GkDieP9KRL5gX4uj+L5GzepmJW1rLaQthQ9lphr4ceyEyTO
q7wO7dAZx1u4x0Mce0Hi+H0E+r5OBBK+NfGCuylurJGFNSlD8Csux+7cuq8G
2egh8+2x0Quj8QoTqLZ05Fk.TOU7f5SGkIE2cO4CYeLK5oh440x4D06EdR47
Y4U22adZ8pUkUM5WJp7onuTttJJa0pCNoPbcRgQUSJBVqjJBSHs+hxbcRggu
lSJSKWrHWJ.1cR4+Ppy2sdX57ho+TzK4U4SNjLBcbYTZbbqPgSSZ+EhonHoF
hnGW+3iyy2keOqPiJNrPK9zBsmpd9Q0aaySfu+VcF0z8.pV+a+9J46KZd15k
Se4QoghZoR3KMMqp+Me0WUWzjW+vykkOOO+A4bf5AekTqUpqtHao7eTmm8Uy
J+zx4kYy9pgQgMNUMYjl.VOv9ouRDWS80k4eRNH1SX+bVygUNOg7fQ.AAME9
kZUbrqhCNcDJNJdJ5WWfh95uNJt0T3xHTT9757nXWW.qkQXA8AVRp.ikqhIL
+jTrwnj5opxE0eYwikycUzPQJQCEqr6KHdJTHiPgRc9b4zryqmRfkPRi8bLk
SnRgiuRk3CKUvNJUdLa4yStencXwCQiPslAEqTYfsAaUebSpPSGg5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