++OPGELOST ++ Scroll text met PCF8574A I2C

Hallo Allen,

Ik probeer hem eens op het NL-Forum,

Ik ben bezig met een I2c schakeling , wat nu werkt,
De LCD gekoppeld aan een PCF8574A ,
Nu heb ik in ROW 1 een scrollende text , dit werkt goed.
Maar wil een vaste text in ROW 2 , dit werkt dus niet , deze scrollt namelijk ook mee wat dus niet de bedoeling is.

Dit is mijn setup:

En dit is mijn Sketch:

/*
  Scroll
  * this sketch scrolls text left when tilted
  * text scrolls right when not tilted.
 */

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

// initialize the library with the numbers of the interface pins

const int numRows = 2;
const int numCols = 16;



const char textString[] = "                  * ArduinoPat *      ";
const int textLen = sizeof(textString) -1; // the number of characters

LiquidCrystal_I2C lcd(0x38,16,2);

void setup()
{
   lcd.init();
   lcd.backlight();
  // set up the LCD's number of columns and rows:
  
  lcd.print(textString);
}

void loop()
{
  {
    // here if tilted left so scroll text left
   
    for (int position = 0; position  < textLen; position++)
    {
      lcd.scrollDisplayLeft();
      delay(150);
    }
  }
 
  {
    // here if previously tilted but now flat, so scroll text right
    
    for (int position = 0; position  < textLen; position++)
    {
      lcd.scrollDisplayRight();
      delay(150);
    }
  }
}

Ik hoop dat iemand mij hiermee op weg kan helpen,

Alvast bedankt,

ArduinoPat

simpelste manier is om zelf de geshifte tekst naar regel 1 te schrijven
maak een array van char waar de tekst in staat ,

shift deze en schrijf hem geheel weg naar regel 1.

een andere oplossing is beide regels constant opnieuw te schrijven en bij de onderste de positie niet te veranderen.

lcd.setCursor(0,0); // set first line on the LCD
lcd.print( "scrollende tekst");
lcd.setCursor(0,1); // set second line on the LCD
lcd.print( "vaste tekst");

besef wel goed, dat met je delay's om te scrollen, je niets anders kan gaan doen naast het tonen van tekst op je LCD scherm, zolang de tekst aan het scrollen is. kijk eens naar blink without delay.

Beste JO3RI,

Dit gaat helaas niet op , beide teksten scrollen ook met deze code ??
Ik heb al van alles geprobeerd, maar ben er nog niet uit :0

/*
  Scroll
  * this sketch scrolls text left when tilted
  * text scrolls right when not tilted.
 */

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

// initialize the library with the numbers of the interface pins

const int numRows = 2;
const int numCols = 16;



const char textString[] = "                  * ArduinoPat *      ";
const int textLen = sizeof(textString) -1; // the number of characters

LiquidCrystal_I2C lcd(0x27,16,2);

void setup()
{
   lcd.init();
   lcd.backlight();
  // set up the LCD's number of columns and rows:
  lcd.setCursor(0, 1);
  lcd.print(textString);
  
  lcd.setCursor(0, 0);
  lcd.print("Vaste Tekst");
}

void loop()
{
  {
    // here if tilted left so scroll text left
   
    for (int position = 0; position  < textLen; position++)
    {
      
      lcd.scrollDisplayLeft();
      delay(150);
    }
  }
 
  {
    // here if previously tilted but now flat, so scroll text right
    
    for (int position = 0; position  < textLen; position++)
    {
     
      lcd.scrollDisplayRight();
      delay(150);
    }
  }
}

Misschien iemnand nog een optie ??

vrijwel altijd zitten de 2 regels in een lineair/ sequentieel geheugen, en is de scroll geimplementeerd als schuiven in het geheugen. En dan schuift alles ..

probeer dit eens.

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

const int numRows = 2;
const int numCols = 16;

const char textString[] = "                  * ArduinoPat *        ";
const int textLen = sizeof(textString) -1; // the number of characters

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup()
{
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Vaste Tekst");
}

void loop()
{
    for (int position = 0; position  < textLen; position++)
    {
      lcd.setCursor(0,1);  // of moet dit zijn 1,0?
      lcd.print(textString[position])
      delay(150);
    }
    for (int position = textLen; position  >0; position--)
    {
      lcd.setCursor(0,1);
      lcd.print(textString[position])
      delay(150);
    }
}

Goedenavond Rob,

Helaas gaat dit ook niet lukken :0
Nu laat die de vaste tekst staan op rij 1 , en zie ik in rij 2 nu in het eerste blok steeds 1 letter weergeven ( van mijn scrolltext )

Ik denk wat ik wil niet gaat lukken ,

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

const int numRows = 2;
const int numCols = 16;

const char textString[] = "                  * ArduinoPat *        ";
const int textLen = sizeof(textString) -1; // the number of characters

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup()
{
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Vaste Tekst");
}

void loop()
{
    for (int position = 0; position  < textLen; position++)
    {
      lcd.setCursor(0,1);  // of moet dit zijn 1,0?
      lcd.print(textString[position]);
      delay(150);
    }
    for (int position = textLen; position  >0; position--)
    {
      lcd.setCursor(0,1);
      lcd.print(textString[position]);
      delay(150);
    }
}

Maar voor als nog hartelijk dank voor jou input !!

ik bedoelde dat je de cursor positie kan wijzigen en dus niet gebruikt maakt van de scroll functie die in de library zit.

for (int i = -16; i < 32; i++)
{
  lcd.setCursor(i,0); // set first line on the LCD
  lcd.print( "scrollende tekst");
  lcd.setCursor(0,1); // set second line on the LCD
  lcd.print( "vaste tekst");
  delay (150);
}

Een andere mogelijkheid is om inderdaad een buffer te gebruiken, maar dan heb je er wel 2 nodig: eentje voor lijn 1 en eentje voor lijn 2. Die moeten dan beiden 17 bytes groot zijn. Je kopieert dan telkens de tekst naar een andere plaats in de buffer en toont telkens bufffer1 op lijn 1 en buffer2 op lijn2.

2e poging

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

const int numRows = 2;
const int numCols = 16;

const char textString[] = "                  * ArduinoPat *        ";
const int textLen = sizeof(textString) -1; // the number of characters

LiquidCrystal_I2C lcd(0x27, numCols, numRows );

void setup()
{
  lcd.init();
  lcd.backlight();

  // vaste text
  lcd.setCursor(0,1);
  lcd.print("vaste text");
}

void loop()
{
  // scroll text
  for (int position = 0; position  < textLen; position++)
  {
    lcd.setCursor(0, 0); 
    lcd.print(&textString[position])       // was het & (adress) vergeten
    delay(100);
  }
  for (int position = textLen; position  >0; position--)
  {
    lcd.setCursor(0,0);
    lcd.print(&textString[position]);
    delay(100);
  }
}

probeer eens

Hoi Rob,

Helemaal super , dit blijkt te werken !!! :smiley:

Many thanks ,

Sorry voor late reply ,

Fijne dagen toegewenst en een prettige jaarwisseling voor 2013

Groet,

Patrick, ArduinoPat, Maarssen

Goed om te horen dat het werkt,

net op tijd om een automatische Arduino nieuwjaars afteller te maken :wink:

Zoeen met een timer die terugloopt, nog 255 uur... 254 uur ... nog 5 4 3 2 1 Happy Newyear "