Go Down

Topic: Problem when using auto scroll function in I2C LCD display with arduino (Read 47 times) previous topic - next topic

sreekanthmp

any can help me

I want to scroll the text "GEAR SHIFTING" in initial screen of my display.scrolling will continue until unless any push button presss.this is my programme.

Code: [Select]

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
const uint32_t debounceTime = 100; 
const uint8_t fwd     = A2;
const uint8_t rvs     = 8; 
const uint8_t up      = 2;
const uint8_t dwn     = 3;
const uint8_t ledPin  = 7; //in place of led, relay will fit on actual circuit
const uint8_t ledPin1 = 6;
const uint8_t ledPin2 = 4;
const uint8_t ledPin3 = 5;
int initialsatate1;
int finalstate1;
int initialsatate2;
int finalstate2;
int count=0;

const bool switchOn  = true;     // using INPUT_PULLUP
const bool switchOff = false;
const bool switchOn1  = true;     // using INPUT_PULLUP
const bool switchOff1 = false;
bool lastState   = switchOff;
bool newState    = switchOff;
bool toggleState = true;
bool lastState1   = switchOff1;
bool newState1    = switchOff1;
bool toggleState1 = true;

void setup()
{
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("GEAR SHIFTING");
  lcd.backlight();
  pinMode ( rvs, INPUT_PULLUP );
  pinMode ( fwd, INPUT_PULLUP );
  pinMode ( ledPin, OUTPUT );
  pinMode ( ledPin1, OUTPUT );
  pinMode ( up, INPUT_PULLUP );
  pinMode ( dwn, INPUT_PULLUP );
  pinMode ( ledPin2, OUTPUT );
  pinMode ( ledPin3, OUTPUT );
} // setup

void loop ()

 
{    newState = digitalRead( fwd );
     newState1 = digitalRead( rvs );

if( lastState != newState ) // state changed
    {
      delay( debounceTime );
      lastState = newState;
      if( newState == switchOn && toggleState == true )
   
    {
      toggleState = false;
      toggleState1 = true;
      digitalWrite( ledPin, HIGH );//FWD RELAY WILL ACTIVATE.
      digitalWrite( ledPin1, LOW );
      lcd.setCursor(7,0);
      lcd.print("      ");
      lcd.setCursor(0,0);
      lcd.print("FORWARD");
    }
    }
 
  if( lastState1 != newState1 )
  {
      delay( debounceTime );
     lastState1 = newState1;
     if( newState1 == switchOn1 && toggleState1 == true )
    {
      toggleState1 = false;
      toggleState = true;
      digitalWrite( ledPin, LOW );
      digitalWrite( ledPin1, HIGH );//RVS RELAY WILL ACTIVATE
      lcd.setCursor(7,0);
      lcd.print("      ");
      lcd.setCursor(0,0);
      lcd.print("REVERSE");
    }
  }
  if (digitalRead(up) == HIGH)
  {
      digitalWrite( ledPin2, HIGH );//SPEED UP RANGE RELAY WILL ACTIVATE ON EACH PRESS
  }
  else
  {
      digitalWrite( ledPin2, LOW );
  }
  if (digitalRead(dwn) == HIGH)
  {
      digitalWrite( ledPin3, HIGH );//SPEED DOWN RELAY WILL ACTIVATE ON EACH PRESS.
  }
  else{
       digitalWrite( ledPin3, LOW );
  }
  //////////program for speed range display UP or DOWN///////
      finalstate1 = digitalRead(up);
 if  (finalstate1!=initialsatate1)
 {
      delay( debounceTime );
      finalstate1 = digitalRead(up);
  {
      if (finalstate1==HIGH&&count<4)
  {
      count++;
     lcd.setCursor(0,1);
     lcd.print(count);
  }
      initialsatate1=finalstate1;
  }}
      finalstate2 = digitalRead(dwn);
 if  (finalstate2!=initialsatate2)
 {
     delay( debounceTime );
     finalstate2 = digitalRead(dwn);
  {
     if (finalstate2==HIGH&&count>1)
  {
     count--;
     lcd.setCursor(0,1);
     lcd.print(count);
  }
     initialsatate2=finalstate2;

}}}//LOOP ENDS.

 




i have use "lcd.autoscroll()" in void setup but it will scrolled the all parameters.

please help...

PaulS

Quote
i have use "lcd.autoscroll()" in void setup but it will scrolled the all parameters.
What does "all the parameters" mean?

If you want to scroll only one line, YOU need to write the code to do that. You display "Gear shifting   ", then "ear shifting   G", then "ar shifting   Ge", etc. Not hard at all. Two for loops is all.
The art of getting good answers lies in asking good questions.

sreekanthmp

This program for gear shifting display,

Initially display shows :"GEAR SHIFTING" (I need to scroll in one line)
 
When i press the push button display shows parameters as program.


If you want to scroll only one line, YOU need to write the code to do that. You display "Gear shifting   ", then "ear shifting   G", then "ar shifting   Ge", etc. Not hard at all. Two for loops is all.
please explain ,i don't get.

Go Up