Help Lcd1602 + Esp12F Arduino Project

Hello

I would like to done a project domotic with a old Lcd shield 1602 and a Esp12F

I have followed this video :

I have test the two files INO of this video I have succeed for a Arduino file here :

#include <LiquidCrystal.h>
const int rs=D1, en=D2, d4=D4, d5=D5, d6=D6, d7=D7;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7); //select the pins used on the LCD panel

void setup(){
  
   lcd.begin(16, 2);
   lcd.clear();
   Serial.begin(9600);    
}
 
void loop(){

 lcd.setCursor(0,1);
 lcd.clear();
 lcd.print(analogRead(A0)); //read anolog pin A0
 delay(100);
 Serial.println("Moniteur Série prêt");
 Serial.println(analogRead(A0));

}

For the second file INO here I have error :

#define SELECT_KEY   1
#define LEFT_KEY     2
#define DOWN_KEY     3
#define UP_KEY       4
#define RIGHT_KEY    5

#include <LiquidCrystal.h>
const int rs=D1, en=D2, d4=D4, d5=D5, d6=D6, d7=D7;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7); //select the pins used on the LCD panel

int menuPos = 0;

String menuLines[6] =
{
  "Settings",
  "Reset",
  "Main Site",
  "Server IP",
  "Get Data",
  "Return"
};

void setup() {

  lcd.begin( 16, 2 );
  
}

void loop() {

   lcd.clear();
   lcd.print(">"); lcd.print( menuLines[ menuPos ] );
   lcd.setCursor(0, 1); lcd.print( menuLines[ menuPos + 1] );

   if( getKeyID() == UP_KEY ) menuPos--;
   if( getKeyID() == DOWN_KEY ) menuPos++;

   if( menuPos < 0 ) menuPos = 0;
   if( menuPos > 5 ) menuPos = 5;

   delay(100);
  

}

int getKeyID()
{
  int aRead = analogRead( A0 );

  if( aRead > 500 ) return 0;                //no key is pressed
  if( aRead > 420  ) return SELECT_KEY;      //select key 
  if( aRead > 350  ) return LEFT_KEY;        //left key
  if( aRead > 300  ) return DOWN_KEY;        //right key
  if( aRead > 150   ) return UP_KEY;         //up key
  if( aRead < 30   ) return RIGHT_KEY;       //right key
}

Here the error I have at the compilation :

C:\Users\Claude\Documents\Sketchs Arduino\nodemcu-lcd-shield-main\shield_ENG\shield_ENG.ino: In function 'int getKeyID()':
C:\Users\Claude\Documents\Sketchs Arduino\nodemcu-lcd-shield-main\shield_ENG\shield_ENG.ino:56:1: error: control reaches end of non-void function [-Werror=return-type]
   56 | }
      | ^
cc1plus.exe: some warnings being treated as errors

exit status 1

Compilation error: control reaches end of non-void function [-Werror=return-type]

Does anyone has an explanation, sorry I'am newbee with arduino

Hello
I have found a response (for the general culture or Arduino....and all the new bee like me)

It needeed to add a line at the end "return 0"

The sketche become like this :


#define SELECT_KEY   1
#define LEFT_KEY     2
#define DOWN_KEY     3
#define UP_KEY       4
#define RIGHT_KEY    5

#include <LiquidCrystal.h>
const int rs=D1, en=D2, d4=D4, d5=D5, d6=D6, d7=D7;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7); //select the pins used on the LCD panel

int menuPos = 0;

String menuLines[6] =
{
  "Settings",
  "Reset",
  "Main Site",
  "Server IP",
  "Get Data",
  "Return"
};

void setup() {

  lcd.begin( 16, 2 );
  
}

void loop() {

   lcd.clear();
   lcd.print(">"); lcd.print( menuLines[ menuPos ] );
   lcd.setCursor(0, 1); lcd.print( menuLines[ menuPos + 1] );

   if( getKeyID() == UP_KEY ) menuPos--;
   if( getKeyID() == DOWN_KEY ) menuPos++;

   if( menuPos < 0 ) menuPos = 0;
   if( menuPos > 5 ) menuPos = 5;

   delay(100);
  

}

int getKeyID()
{
  int aRead = analogRead( A0 );

  if( aRead > 500 ) return 0;                //no key is pressed
  if( aRead > 420  ) return SELECT_KEY;      //select key 
  if( aRead > 350  ) return LEFT_KEY;        //left key
  if( aRead > 300  ) return DOWN_KEY;        //right key
  if( aRead > 150   ) return UP_KEY;         //up key
  if( aRead < 30   ) return RIGHT_KEY;       //right key

  return 0;
}

Working now?

If you have problems "String()"

Try an array of strings


char *menuLines[] = {
  "Settings",
  "Reset",
  "Main Site",
  "Server IP",
  "Get Data",
  "Return"
};

The following probably happens when you go "below" SETTINGS or "above RETURN... you do not error check for too many UP_KEY or DOWN_KEY

Compilation error: control reaches end of non-void function [-Werror=return-type]

@Railroader

Yes the solution I propose give 100% results and the sketche function all OK

@xfpd

I will try in the next day your proposition of solution for complete the post and help anyone
Thanks

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.