Nokia 5110 Library U8glib Error Fault Will Not Compile

There are 3 libraries used for this sketch: “AccelStepper” to control a stepper motor, “Keypad” to map the keys of the keypad and “U8glib” to draw information on the nokia 5110 LCD.

The sketch will not compile and gives the following error message see photo capture.
I'm using the Arduino Mega2560.

Hoping members here can help resolve this issue. Thanks, Ron

Cannot see much of the error message.

Please post the full text of any and all error messages.

Not a picture showing a small piece of one error message out of many.

Sorry. First attachment shows compile fault. Second attachment shows upload timeout fault.
Ron

That's a compile warning (something syntactically valid, but which is felt to be sufficiently bad programming practice that they warn you), not an error. It is compiling successfully - if it doesn't, it won't try to upload, because it would have nothing to upload.

Do you have a string containing "!!!" anywhere in your code? Remove it if so - due to a bootloader bug (fixed long ago, but the bad one is preloaded on many mega2560 clones), this causes the compilation to fail with timeout errors when it gets to it.

You can select the compiler/upload messages and copy/paste them as text - please do that next time you need to post messages like that, not a screenshot. I'm pretty sure there's more above the compiler warnings, for example. And you should be using verbose compiler and upload output (in preferences) when investigating issues (I use it all the time) - which will output a hell of a lot more messages - and for that you absolutely do need to copy/paste it as text.

This sketch is giving me the U8glib library and Timeout issue as shown above. The !!! string is not found
in the code I'm using. My mega2560 is actually a Funduino product. Thanks.

/* Arduino Control Stepper with Keypad and LCD
 
Created by Yvan / https://Brainy-Bits.com
This code is in the public domain...
You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!
 
*/
 
#include  <AccelStepper.h>// AccelStepper Library
#include   <Keypad.h>// Keypad Library
#include "U8glib.h"  // U8glib for Nokia LCD
 
// Variables to hold entered number on Keypad
volatile int firstnumber=99;  // used to tell how many numbers were entered on keypad
volatile int secondnumber=99;
volatile int thirdnumber=99;
 
// Variables to hold Distance and CurrentPosition
int keyfullnumber=0;  // used to store the final calculated distance value
String currentposition = "";  // Used for display on Nokia LCD
 
 
// Keypad Setup
const byte ROWS = 4; // Four Rows
const byte COLS = 4; // Four Columns
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {22, 24, 26, 28}; // Arduino pins connected to the row pins of the keypad
byte colPins[COLS] = {31, 33, 35, 37}; // Arduino pins connected to the column pins of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );  // Keypad Library definition
 
 
// U8glib Setup for Nokia LCD
#define backlight_pin 11
U8GLIB_PCD8544 u8g(3, 4, 6, 5, 7);  // Arduino pins connected to Nokia pins:
                                    // CLK=3, DIN=4, CE=6, DC=5, RST=7
                                    
                                    
// AccelStepper Setup
AccelStepper stepper(1, A0, A1);  // 1 = Easy Driver interface
                                  // Arduino A0 connected to STEP pin of Easy Driver
                                  // Arduino A1 connected to DIR pin of Easy Driver
                                  
 
 
void setup(void) {
  
  //  Light up the LCD backlight LEDS
  analogWrite(backlight_pin, 0);  // Set the Backlight intensity (0=Bright, 255=Dim)
    
  //  AccelStepper speed and acceleration setup
  stepper.setMaxSpeed(1500);  // Not to fast or you will have missed steps
  stepper.setAcceleration(400);  //  Same here
  
  // Draw starting screen on Nokia LCD
  u8g.firstPage();
  do {
  u8g.drawHLine(0, 15, 84);
  u8g.drawVLine(50, 16, 38);
  u8g.drawHLine(0, 35, 84); 
  u8g.setFont(u8g_font_profont11);
  u8g.drawStr(0, 10, "ENTER DISTANCE");
  u8g.drawStr(62, 29, "MM");
  u8g.drawStr(4, 46, "cur-pos");
  }
  while( u8g.nextPage() );
  
}
 
 
void loop(){
  
  char keypressed = keypad.getKey();  // Get value of keypad button if pressed
  if (keypressed != NO_KEY){  // If keypad button pressed check which key it was
    switch (keypressed) {
      
      case '1':
        checknumber(1);
      break;
        
      case '2':
        checknumber(2);
      break;
 
      case '3':
        checknumber(3);
      break;
 
      case '4':
        checknumber(4);
      break;
 
      case '5':
        checknumber(5);
      break;
 
      case '6':
        checknumber(6);
      break;
 
      case '7':
        checknumber(7);
      break;
 
      case '8':
        checknumber(8);
      break;
 
      case '9':
        checknumber(9);
      break;
 
      case '0':
        checknumber(0);
      break;
 
      case '*':
        deletenumber();
      break;
 
      case '#':
        calculatedistance();
      break;
    }
  }
 
}
 
void checknumber(int x){
  if (firstnumber == 99) { // Check if this is the first number entered
    firstnumber=x;
    String displayvalue = String(firstnumber);  //  Transform int to a string for display
    drawnokiascreen(displayvalue); // Redraw Nokia lcd
    
  } else {
    if (secondnumber == 99) {  // Check if it's the second number entered
      secondnumber=x;
      String displayvalue = (String(firstnumber) + String(secondnumber));
      drawnokiascreen(displayvalue);
 
    } else {  // It must be the 3rd number entered
      thirdnumber=x;
      String displayvalue = (String(firstnumber) + String(secondnumber) + String(thirdnumber));
      drawnokiascreen(displayvalue);
 
    }
  }
}
 
 
void deletenumber() {  // Used to backspace entered numbers
  if (thirdnumber !=99) {
      String displayvalue = (String(firstnumber) + String(secondnumber));
      drawnokiascreen(displayvalue);
 
    thirdnumber=99;
  } 
  else {
    if (secondnumber !=99) {
      String displayvalue = String(firstnumber);
      drawnokiascreen(displayvalue);
 
      secondnumber=99;
   } 
   else {
     if (firstnumber !=99) {
       String displayvalue = "";
       drawnokiascreen(displayvalue);
 
       firstnumber=99;
      }
    }
  }
}
  
void calculatedistance() {  // Used to create a full number from entered numbers
 
    if (thirdnumber == 99 && secondnumber == 99 && firstnumber != 99) {
      keyfullnumber=firstnumber;
      movestepper(keyfullnumber);
    }
    
    if (secondnumber != 99 && thirdnumber == 99) {
      keyfullnumber=(firstnumber*10)+secondnumber;
      movestepper(keyfullnumber);
    }
    
    if (thirdnumber != 99) {
      keyfullnumber=(firstnumber*100)+(secondnumber*10)+thirdnumber;
      movestepper(keyfullnumber);
    }
    
    resetnumbers(); // Reset numbers to get ready for new entry
  } 
 
 
void movestepper(int z) {  //  Move the stepper
 
  int calculatedmove=((z*1600)/80);  //  Calculate number of steps needed in mm
  stepper.runToNewPosition(calculatedmove);
  currentposition = String(z);
  u8g.firstPage();
  do {
    u8g.drawHLine(0, 15, 84);
    u8g.drawVLine(50, 16, 38);
    u8g.drawHLine(0, 35, 84); 
    u8g.setFont(u8g_font_profont11);
    u8g.drawStr(0, 10, "ENTER DISTANCE");
    u8g.drawStr(62, 29, "MM");
    u8g.drawStr(4, 46, "cur-pos");
    u8g.setPrintPos(57,47);
    u8g.print(currentposition);       
  }
  while( u8g.nextPage() ); 
}
                
void resetnumbers() {  // Reset numbers for next entry
  firstnumber=99;
  secondnumber=99;
  thirdnumber=99;
} 
  
 
void drawnokiascreen(String y) {
 
    u8g.firstPage();
    do {
      u8g.drawHLine(0, 15, 84);
      u8g.drawVLine(50, 16, 38);
      u8g.drawHLine(0, 35, 84); 
      u8g.setFont(u8g_font_profont11);
      u8g.drawStr(0, 10, "ENTER DISTANCE");
      u8g.setPrintPos(0,29);
      u8g.print(y);  // Put entered number on Nokia lcd    
      u8g.drawStr(62, 29, "MM");
      u8g.drawStr(4, 46, "cur-pos");
      u8g.setPrintPos(57,47); 
      u8g.print(currentposition);  //  Display current position of stepper
    }
      while( u8g.nextPage() );
 
}

As I said before, The ug8 "error" is not an error, it is a warning - you can ignore it.

Enable verbose upload and post full output (as text).

DrAzzy:
As I said before, The ug8 "error" is not an error, it is a warning - you can ignore it.

Enable verbose upload and post full output (as text).

DrAzzy: Now that I've figured out verbose output, the amount of upload detail in this file is large.
Is this file going to reveal why my sketch couldn't be validated by Arduino? Thank you, Ron

U8glib mega2560.txt (231 KB)

That's verbose compile output, showing a successful compilation. There are no errors, only warnings. Those can be ignored - they do not indicate a problem. It is not unusual for working code to have warnings.

It looks like you did "verify", not "upload" - and no problems were encountered.

As I've said at least twice before, the problem is not with the code. The compilation is completing successfully. Whenever you see it show the total sketch size, that means it compiled successfully.

You said that you can't upload the sketch, and posted screenshots of a timeout error - that is a problem with the upload process, not the compile process. So I need the verbose output of an attempt to upload the sketch to the board, not just verify it.

DrAzzy:
That's verbose compile output, showing a successful compilation. There are no errors, only warnings. Those can be ignored - they do not indicate a problem. It is not unusual for working code to have warnings.

It looks like you did "verify", not "upload" - and no problems were encountered.

As I've said at least twice before, the problem is not with the code. The compilation is completing successfully. Whenever you see it show the total sketch size, that means it compiled successfully.

You said that you can't upload the sketch, and posted screenshots of a timeout error - that is a problem with the upload process, not the compile process. So I need the verbose output of an attempt to upload the sketch to the board, not just verify it.

Yes, I acknowledge no problem with the U8glib library.
I've attached the verbose text file related to an attempt to upload sketch to the mega2560
Hope I've finally got what is needed for a reveal, so to speak.

Arduino Verify Upload.txt (128 KB)

That was.... less informative than I'd hoped.

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega2560 -cwiring -PCOM10 -b115200 -D -Uflash:w:C:\Users\Ron\AppData\Local\Temp\builda69e557c0b32fe969b799da862742796.tmp/Stepper_Keypad_LCD.ino.hex:i 

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM10
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done.  Thank you.

I can't tell if it's driver problems (it could be - since it sounds like you've never used the board successfully on that system), or hardware problem. Is there anything connected to pins 0 or 1? You can't have anything on those pins when uploading. What serial chip does your mega use? Is the mega showing up as working in device manager?

DrAzzy:
That was.... less informative than I'd hoped.
I can't tell if it's driver problems (it could be - since it sounds like you've never used the board successfully on that system), or hardware problem. Is there anything connected to pins 0 or 1? You can't have anything on those pins when uploading. What serial chip does your mega use? Is the mega showing up as working in device manager?

First time board has been used in my system.
Pins 0 or 1 not connected.
Serial chip don't know.
Device manager indicates (COM10) Arduino/Genuino mega or mega 2560.
Windows has determined the driver software for the Arduino Mega 2560 at (COM10) is up to date.

The RX TX LEDs never light which indicates to me that the Arduino is not transmitting or receiving data from the computer.
L LED blinks constantly.
The green LED is ON indicating Arduino has power.

I will be swapping out this mega2560 for a new board soon and start fresh.
Thank you for your time, help and suggestions.
Ron