LCD QC12864B (ST7920) issues with U8GLIB SPI mode

Hello,
I'm new here. I have some trouble with my QC12864B LCD display.
It works fine with the "Hello World" code with configuartion: U8GLIB_ST7920_128X64_4X u8g(10);

But with my code it show nothing.

the wirering:

Can somebody help me please?

the code is:

#include <U8glib.h>
#include <PinChangeInt.h>
#include <PinChangeIntConfig.h>

U8GLIB_ST7920_128X64_4X u8g(10);

#define NO_PORTB_PINCHANGES
#define NO_PORTC_PINCHANGES
#define NO_PIN_STATE

#define TRUE 1
#define FALSE 0 

#define clock 8
#define data 9

#define clock1 6
#define data1 7

#define clock2 4
#define data2 5

#define UP A0
#define ZERO A1
#define DOWN A2
#define EDIT A3



#define bit_read_time 10 
unsigned char bit_timer[3];
unsigned char bit_timer_flag[3];
unsigned char bit_counter[3];
unsigned char bit_buffer[3][24];
unsigned char bit_temp[3];
unsigned long time[3];
long bit_result[3];
long bit_result_temp[3];
long bit_result_offset[3];

unsigned char Display [3] [6];

unsigned char menue = 0;
unsigned char menue_edit = 0;
unsigned char menue_edit_state;

unsigned char pinstate[4];
unsigned char error_flag = 0;



void draw(void) {
  // graphic commands to redraw the complete screen should be placed here  
if (error_flag == FALSE)  
{  u8g.setFont(u8g_font_fub11);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0,17 , "X");
  u8g.drawStr(0,39, "Y");
  u8g.drawStr(0,61 , "Z");
  u8g.drawBox(96,15,2,2);
  u8g.drawBox(96,37,2,2);
  u8g.drawBox(96,59,2,2);
  
  switch (menue){
  case 0:
    u8g.drawStr(10,18 , "*");
   
     if (menue_edit_state == TRUE)
       { switch (menue_edit){
         case 0: u8g.drawLine(112, 18, 124, 18);break;
         case 1: u8g.drawLine(98, 18, 110, 18);break;
         case 2: u8g.drawLine(82, 18, 94, 18);break;
         case 3: u8g.drawLine(68, 18, 80, 18);break;
         case 4: u8g.drawLine(54, 18, 66, 18);break;
       }
        }
   
 
   
   break;
  
    case 1:
    u8g.drawStr(10,40 , "*");
    
         if (menue_edit_state == TRUE)
       { switch (menue_edit){
         case 0: u8g.drawLine(112, 40, 124, 40);break;
         case 1: u8g.drawLine(98, 40, 110, 40);break;
         case 2: u8g.drawLine(82, 40, 94, 40);break;
         case 3: u8g.drawLine(68, 40, 80, 40);break;
         case 4: u8g.drawLine(54, 40, 66, 40);break;
       }
        }
  
   break;
   
   case 2:
    u8g.drawStr(10,62 , "*");
    
        if (menue_edit_state == TRUE)
       { switch (menue_edit){
         case 0: u8g.drawLine(112, 62, 124, 62);break;
         case 1: u8g.drawLine(98, 62, 110, 62);break;
         case 2: u8g.drawLine(82, 62, 94, 62);break;
         case 3: u8g.drawLine(68, 62, 80, 62);break;
         case 4: u8g.drawLine(54, 62, 66, 62);break;
       }
        }
   break;
  }
  //----------------------------------------
  u8g.setFont(u8g_font_fub17);
  for (int i=0; i<=2;i++)
  {
   u8g.setPrintPos(112,17 + (i*22));
  u8g.print(Display[i] [0]);
  u8g.setPrintPos(98,17 + (i*22));
  u8g.print(Display[i][1]);
  u8g.setPrintPos(82,17 + (i*22));
  u8g.print(Display[i][2]);
  if (Display[i][3] == 0 && Display[i][4] == 0) u8g.drawStr(68,20 + (i*22), " ");
  else {
  u8g.setPrintPos(68,17 + (i*22));
  u8g.print(Display[i][3]);}  
  if (Display[i][4] == 0 ) u8g.drawStr(54,17 + (i*22), " ");
  else {
  u8g.setPrintPos(54,17 + (i*22));
  u8g.print(Display[i] [4]);}  
 
  if (Display[i][5] == 0) u8g.drawStr(37,15 + (i*22), " ");
  else {u8g.drawStr(37,15 + (i*22), "-");}
  }
 //----------------------------------------
  
}  
else {u8g.setFont(u8g_font_fub11);
      u8g.drawStr(0,20 , " change to mm");
      u8g.drawStr(0,40 , " and press edit");
}
   
}

void cal_print_number (long Zahl,unsigned char zeile)			       
{		
	unsigned char Zehntausender;
	unsigned char Tausender;
	unsigned char Hunderter;
	unsigned char Zehner;
	unsigned char Einer;
        unsigned char minus;	
		
		if (Zahl < 0)
		{	minus = TRUE;
			Zahl = -Zahl;
		}else minus= FALSE;
		
		Zehntausender = Zahl / 10000;	
		Tausender = (Zahl/1000) - Zehntausender*10 ;	
		Hunderter = (Zahl/100) - Zehntausender*100 - Tausender*10;	
		Zehner = (Zahl/10) - Zehntausender*1000 - Tausender*100 - Hunderter*10;	
		Einer = Zahl - Zehntausender*10000 - Tausender*1000 - Hunderter*100 - Zehner*10;		
		
		Display[zeile][0] = Einer;
		if ((Tausender == 0) && (Zehntausender == 0) && (Hunderter ==0 ) && (Zehner == 0))
		{	Display[zeile][1] = FALSE;
		}else Display[zeile][1] = Zehner;
		
		if ((Tausender == 0) && (Zehntausender == 0) && (Hunderter ==0))
		{	Display[zeile][2] = FALSE;
		}else Display[zeile][2] = Hunderter;
		
		if ((Tausender == 0) && (Zehntausender == 0))
		{	Display[zeile][3] = FALSE;
		}else Display[zeile][3] = Tausender;
		
		if ((Zehntausender == 0))
		{  Display[zeile][4] = FALSE;
		}else Display[zeile][4] = Zehntausender;
		
		if (minus==TRUE)
		{     Display[zeile][5] = TRUE;
		}else Display[zeile][5] = FALSE;
		
		
		
		
	}

void convert_bit_buffer(char buffer){		
				
		
		long bit_result_temp = 0;
		for (int_fast8_t i = 0; i < 16; i++) {
		bit_result_temp = (bit_result_temp << 1) | bit_buffer[buffer][15-i];
		}	
		
		if (bit_buffer [buffer][20] == TRUE) bit_result_temp = -bit_result_temp;
		if (bit_buffer[buffer][23] == TRUE) error_flag = TRUE;	
	
		bit_result[buffer] = bit_result_temp;	
		
}


void setup(void) {
  
  pinMode(clock, INPUT);     //set the pin to input
  digitalWrite(clock, HIGH); //use the internal pullup resistor
  pinMode(data, INPUT);     //set the pin to input
  digitalWrite(data, HIGH); //use the internal pullup resistor
  PCintPort::attachInterrupt(clock, trigger,RISING );
  
  pinMode(clock1, INPUT);     //set the pin to input
  digitalWrite(clock1, HIGH); //use the internal pullup resistor
  pinMode(data1, INPUT);     //set the pin to input
  digitalWrite(data1, HIGH); //use the internal pullup resistor
  PCintPort::attachInterrupt(clock1, trigger1,RISING );
  
  pinMode(clock2, INPUT);     //set the pin to input
  digitalWrite(clock2, HIGH); //use the internal pullup resistor
  pinMode(data2, INPUT);     //set the pin to input
  digitalWrite(data2, HIGH); //use the internal pullup resistor
  PCintPort::attachInterrupt(clock2, trigger2,RISING );
  
  pinMode(UP, INPUT);     //set the pin to input
  digitalWrite(UP, HIGH); //use the internal pullup resistor
  pinMode(ZERO, INPUT);     //set the pin to input
  digitalWrite(ZERO, HIGH); //use the internal pullup resistor
  pinMode(DOWN, INPUT);     //set the pin to input
  digitalWrite(DOWN, HIGH); //use the internal pullup resistor
  
  pinMode(EDIT, INPUT);     //set the pin to input
  digitalWrite(EDIT, HIGH); //use the internal pullup resistor
  
  
  
  
  // flip screen, if required
  // u8g.setRot180();
  
  // set SPI backup if required
  //u8g.setHardwareBackup(u8g_backup_avr_spi);

  // assign default color value
  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);     // white
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setColorIndex(3);         // max intensity
  }
  else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setColorIndex(1);         // pixel on
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB(255,255,255);
  }
  
}

void loop(void) {


  u8g.firstPage();  
  do {
    draw();
    
  } while( u8g.nextPage() );
  


for (int i=0;i<=2;i++)
{
  if ( bit_timer_flag[i] == TRUE)
  { time[i] = millis();
    bit_timer_flag[i] = FALSE;
  }    
  if (bit_read_time <= millis() - time[i]){bit_counter[i]=0; time[i] = millis();}
  bit_result_temp[i] = bit_result[i]+bit_result_offset[i];
  cal_print_number(bit_result_temp[i],i);
  }
  
  if (!digitalRead(EDIT) && menue_edit_state == TRUE && pinstate[0] == FALSE){ menue_edit_state = FALSE; menue_edit = 0;delay(5);pinstate[0] = TRUE;}
  else if (!digitalRead(EDIT) && pinstate[0] == FALSE && menue_edit_state == FALSE)  
  { menue++;
    error_flag = FALSE;
    if (menue >= 3) menue = 0;
    delay(5);
    pinstate[0] = TRUE;
  }

  
    if (!digitalRead(ZERO)&& menue_edit_state == FALSE) bit_result_offset[menue] = -bit_result[menue];
    if (!digitalRead(DOWN)&& pinstate[3] == FALSE && menue_edit_state == FALSE){ bit_result_offset[menue] = -(bit_result[menue] - (bit_result[menue]/2))+ (bit_result_offset[menue]/2);pinstate[3] = TRUE;delay(5);}
    if (!digitalRead(UP)&& menue_edit_state == FALSE) {menue_edit_state = TRUE; pinstate[2] = TRUE;}
    
    
    if (menue_edit_state == TRUE) 
    {
      
      if (!digitalRead(ZERO) && pinstate[1] == FALSE)  
      { menue_edit++;
        if (menue_edit >= 5) menue_edit = 0;
        delay(5);
        pinstate[1] = TRUE;
      }    
      
      
      switch (menue_edit){
      
        case 0:           
           if (!digitalRead(UP)&& pinstate[2] == FALSE){bit_result_offset[menue] = bit_result_offset[menue] + 1; pinstate[2] = TRUE;delay(5);}
           if (!digitalRead(DOWN)&& pinstate[3] == FALSE){bit_result_offset[menue] = bit_result_offset[menue] - 1; pinstate[3] = TRUE;delay(5);}
          break;
          
          case 1:           
           if (!digitalRead(UP)&& pinstate[2] == FALSE){bit_result_offset[menue] = bit_result_offset[menue] + 10; pinstate[2] = TRUE;delay(5);}
           if (!digitalRead(DOWN)&& pinstate[3] == FALSE){bit_result_offset[menue] = bit_result_offset[menue] - 10; pinstate[3] = TRUE;delay(5);}
          break;
          
          case 2:           
           if (!digitalRead(UP)&& pinstate[2] == FALSE){bit_result_offset[menue] = bit_result_offset[menue] + 100; pinstate[2] = TRUE;delay(5);}
           if (!digitalRead(DOWN)&& pinstate[3] == FALSE){bit_result_offset[menue] = bit_result_offset[menue] - 100; pinstate[3] = TRUE;delay(5);}
          break;
          
          case 3:           
           if (!digitalRead(UP)&& pinstate[2] == FALSE){bit_result_offset[menue] = bit_result_offset[menue] + 1000; pinstate[2] = TRUE;delay(5);}
           if (!digitalRead(DOWN)&& pinstate[3] == FALSE){bit_result_offset[menue] = bit_result_offset[menue] - 1000; pinstate[3] = TRUE;delay(5);}
          break;
          
          case 4:           
           if (!digitalRead(UP)&& pinstate[2] == FALSE){bit_result_offset[menue] = bit_result_offset[menue] + 10000; pinstate[2] = TRUE;delay(5);}
           if (!digitalRead(DOWN)&& pinstate[3] == FALSE){bit_result_offset[menue] = bit_result_offset[menue] - 10000; pinstate[3] = TRUE;delay(5);}
          break;
      
      
      
      }  
      
      
      
      
      
      
       
    }
  if (digitalRead(EDIT)) pinstate[0] = FALSE;
  if (digitalRead(ZERO)) pinstate[1] = FALSE;
  if (digitalRead(UP)) pinstate[2] = FALSE;
  if (digitalRead(DOWN)) pinstate[3] = FALSE;
}




void trigger()
{  
        if (!digitalRead(data)) bit_temp[0] =0;
	else bit_temp[0] =1;


	if (bit_counter[0] == 0)
	{ bit_timer_flag[0] = TRUE;
	}
 
	
	if (bit_counter[0] <= 24)
	{	bit_buffer[0][bit_counter[0]]= bit_temp[0];
		bit_counter[0]++;
	}
	if (bit_counter[0] >= 24){bit_counter[0]=0;time[0]=0; convert_bit_buffer(0);} 
}

void trigger1()
{ if (!digitalRead(data1)) bit_temp[1] =0;
	else bit_temp[1] =1;


	if (bit_counter[1] == 0)
	{ bit_timer_flag[1] = TRUE;
	}
 
	
	if (bit_counter[1] <= 24)
	{	bit_buffer[1][bit_counter[1]]= bit_temp[1];
		bit_counter[1]++;
	}
	if (bit_counter[1] >= 24){bit_counter[1]=0;time[1]=0; convert_bit_buffer(1);} 

}
void trigger2()
{
  
   if (!digitalRead(data2)) bit_temp[2] =0;
	else bit_temp[2] =1;


	if (bit_counter[2] == 0)
	{ bit_timer_flag[2] = TRUE;
	}
 
	
	if (bit_counter[2] <= 24)
	{	bit_buffer[2][bit_counter[2]]= bit_temp[2];
		bit_counter[2]++;
	}
	if (bit_counter[2] >= 24){bit_counter[2]=0;time[2]=0; convert_bit_buffer(2);} 

}

here you can download the code:
http://muck-solutions.com/?page_id=439

Please edit your opening post, select all code and click the </> button to apply code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project :wink: See About the Installation & Troubleshooting category.

Thanks for your tips, it is the first time I post something. I have edit my post

Have somebody an idea where the problem ist?

Please post this "Hello World" code you speak of.

a7

Here the example "Hello World" code that works:

/*

  HelloWorld.pde
  
  "Hello World!" example code.
  
  >>> Before compiling: Please remove comment from the constructor of the 
  >>> connected graphics display (see below).
  
  Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/
  
  Copyright (c) 2012, olikraus@gmail.com
  All rights reserved.

  Redistribution and use in source and binary forms, with or without modification, 
  are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice, this list 
    of conditions and the following disclaimer.
    
  * Redistributions in binary form must reproduce the above copyright notice, this 
    list of conditions and the following disclaimer in the documentation and/or other 
    materials provided with the distribution.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
  
*/


#include "U8glib.h"

// setup u8g object, please remove comment from one of the following constructor calls
// IMPORTANT NOTE: The following list is incomplete. The complete list of supported 
// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGS102 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGM128_2X u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_SSD1306_128X64 u8g(4, 5, 6, 7);	// SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new white HalTec OLED)
//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0);	// I2C / TWI 
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_NO_ACK|U8G_I2C_OPT_FAST);	// Fast I2C / TWI 
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);	// Display which does not send AC
//U8GLIB_SSD1306_ADAFRUIT_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_SSD1306_ADAFRUIT_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// I2C / TWI 
//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_SSD1306_64X48 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE);	// I2C / TWI 
//U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7);	// SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED)
//U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE);	// I2C / TWI 
//U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_FAST);	// Dev 0, Fast I2C / TWI
//U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NO_ACK);	// Display which does not send ACK
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
//U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE);	// I2C
//U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9, 8);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_UC1611_DOGM240 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
//U8GLIB_UC1611_DOGM240 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16
//U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE);	// I2C
//U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9, 8);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_UC1611_DOGXL240 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_LD7032_60x32 u8g(11, 12, 9, 10, 8);	// SPI Com: SCK = 11, MOSI = 12, CS = 9, A0 = 10, RST = 8  (SW SPI Nano Board)
//U8GLIB_UC1608_240X64 u8g(13, 11, 10, 9, 8);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_UC1608_240X64_2X u8g(13, 11, 10, 9, 8);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_UC1608_240X64 u8g(10, 9, 8);	// HW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_UC1608_240X64_2X u8g(10, 9, 8);	// HW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_UC1608_240X u8g(13, 11, 10, 9, 8);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_UC1608_240X64_2X u8g(13, 11, 10, 9, 8);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_UC1608_240X64 u8g(10, 9, 8);	// HW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_UC1608_240X64_2X u8g(10, 9, 8);	// HW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
//U8GLIB_T6963_128X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
//U8GLIB_HT1632_24X16 u8g(3, 2, 4);		// WR = 3, DATA = 2, CS = 4
//U8GLIB_SSD1351_128X128_332 u8g(13, 11, 8, 9, 7); // Arduino UNO: SW SPI Com: SCK = 13, MOSI = 11, CS = 8, A0 = 9, RESET = 7 (http://electronics.ilsoft.co.uk/ArduinoShield.aspx)
//U8GLIB_SSD1351_128X128_332 u8g(76, 75, 8, 9, 7); // Arduino DUE: SW SPI Com: SCK = 13, MOSI = 11, CS = 8, A0 = 9, RESET = 7 (http://electronics.ilsoft.co.uk/ArduinoShield.aspx)
//U8GLIB_SSD1351_128X128_332 u8g(8, 9, 7); // Arduino: HW SPI Com: SCK = 13, MOSI = 11, CS = 8, A0 = 9, RESET = 7 (http://electronics.ilsoft.co.uk/ArduinoShield.aspx)
//U8GLIB_SSD1351_128X128_HICOLOR u8g(76, 75, 8, 9, 7); // Arduino DUE, SW SPI Com: SCK = 76, MOSI = 75, CS = 8, A0 = 9, RESET = 7 (http://electronics.ilsoft.co.uk/ArduinoShield.aspx)
//U8GLIB_SSD1351_128X128_HICOLOR u8g(8, 9, 7); // Arduino, HW SPI Com: SCK = 76, MOSI = 75, CS = 8, A0 = 9, RESET = 7 (http://electronics.ilsoft.co.uk/ArduinoShield.aspx)
//U8GLIB_SSD1351_128X128GH_332 u8g(8, 9, 7); // Arduino, HW SPI Com: SCK = 76, MOSI = 75, CS = 8, A0 = 9, RESET = 7 (Freetronics OLED)
//U8GLIB_SSD1351_128X128GH_HICOLOR u8g(8, 9, 7); // Arduino, HW SPI Com: SCK = 76, MOSI = 75, CS = 8, A0 = 9, RESET = 7 (Freetronics OLED)
U8GLIB_ST7920_128X64_4X u8g(10);


void draw(void) {
  // graphic commands to redraw the complete screen should be placed here  
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr( 0, 22, "Hello World!");
}

void setup(void) {
  // flip screen, if required
  // u8g.setRot180();
  
  // set SPI backup if required
  //u8g.setHardwareBackup(u8g_backup_avr_spi);

  // assign default color value
  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);     // white
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setColorIndex(3);         // max intensity
  }
  else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setColorIndex(1);         // pixel on
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB(255,255,255);
  }
  
  pinMode(8, OUTPUT);
}

void loop(void) {
  // picture loop
  u8g.firstPage();  
  do {
    draw();
  } while( u8g.nextPage() );
  
  // rebuild the picture after some delay
  //delay(50);
}

To quote a quotable forum member

  I´ve made a low level flight about the sketch.

and I think what you are going to have to do is alter your sketch to try to just print "hello world".

Leave as much as you can, just make the loop very simple.

I see you are using PinChangeInt, I do not think this is your problem, but it seems like it isn't necessary for what you are doing.

You haven't fully embraced the use of some advanced features available in C/C++ which would make your code smaller and easier to read.

A certain clue is variables or functions with names that differ only by a digit at the end.

Above all, you should write the program so that the display portion is separate from the other parts, it would make finding the error(s) in either the display or the computation/flow parts a bit easier.

Perhaps if you couldd say a bit more about what the whole project is supposed to do it would help, maybe.

I don't see any show stoppers. If the Hello World works with the identical hardware, it is as you think - there must be some damage to your attemtp to integrate the LCD OR some interaction between LCD stuff anf the other code.

Not helpful, I know.

You could start with "Hello World!" and add stuff, testing as you do. At some point you will add the thing that breaks it.

Hello World
add some buttons, PinChangeInt if you can't figure out a simpler way to do your buttons.
Serial.print the buttons
Try to put button status on the LCD

Etcetera. Not just N hundred lines it doesn't work why.

You may have already been doing this step-by-step refinement and enhancement.

a7

a7

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