Not sure why I cant get both to work using a Mega 2650. I have 2 files, one for the SPI 128x64, and one that runs 2 16x4 and 1 16x1 (which acts like an 8x2) LCDs, both work perfect, but when I try to merge the files into one, it will only run the 16x4 /1 LCDs and ignore the 128x64.
Can anyone see an issue here?
Here is the code that runs fine with the 16x4 and 16x1 LCDs
#include <LiquidCrystal.h>
LiquidCrystal lcd1(13,12,7,6,5,4);
LiquidCrystal lcd2(11,10,7,6,5,4);
LiquidCrystal lcd3(9,8,7,6,5,4);
void setup()
{
lcd1.begin(16,4);
lcd2.begin(16,4);
lcd3.begin(8,2);
}
void loop()
{
lcd1.setCursor(0,0);
lcd1.print(" 3 LCD 16X4 ");
delay(100);
lcd2.setCursor(0,0);
lcd2.print(" USING ARDUINO ");
delay(100);
lcd3.setCursor(0,0);
lcd3.print("TRIP ODO");
delay(100);
}
Heres the code that works with the 128x64 SPI LCD
#include <U8glib.h>
/* FILE: ARD_12864_Graphic_LCD_Module_HCMODU0015_SPI_Example
DATE: 19/07/13
VERSION: 0.1
REVISIONS:
02/07/13 Created version 0.1
This is an example of how to use the 12864 128x64 graphics LCD module (HCMODU0015).
This example sketch uses the U8glib library to output text and graphics to the
screen in SPI mode.
PINOUT:
MODULE` UNO
K (backlight cathode) GND
A (backlight annode) +5V
PSD (SPI Mode) GND (SEE NOTE)
E (SCK) D13
R/W (MOSI) D11
RS (CS) D10
VDD +5V
VSS GND
Connection to the V0 pin (contrast) is not required.
Note: Some versions of this LCD are shipped with the PSB (parallel/serial select) pin
shorted to VDD by a 0 ohm resistor fitted to R9 on the back of the LCD. This fixes the
LCD in parallel mode. If this resistor is fitted and you wish to use the LCD in serial
mode you will either need to move the resistor to D10 or completely remove it and
ground the PSD pin.
You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used for the purpose of premoting or selling products
that directly compete with Hobby Components Ltd's own range of products.
THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER.
U8glib library copywrite notice:
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
Copyright (c) 2012, olikraus@gmail.com
All rights reserved.
*/
/* Include the U8glib library */
#include "U8glib.h"
/* Define the SPI Chip Select pin */
#define CS_PIN 53
/* Create an instance of the library for the 12864 LCD in SPI mode */
U8GLIB_ST7920_128X64_1X u8g(CS_PIN);
void setup()
{
}
/* Main program */
void loop()
{
/* Start of a picture loop */
u8g.firstPage();
/* Keep looping until finished drawing screen */
do
{
/* Set the font */
u8g.setFont(u8g_font_courB14);
/* Display some text */
u8g.drawStr( 20, 26, "WOO HOO");
u8g.drawStr( 8, 46, " IT WORKS");
/* Draw a simple border */
u8g.drawFrame(5,5,117,54);
u8g.drawFrame(3,3,121,58);
}while(u8g.nextPage());
}
And heres what I smashed together and it doesnt work.....
#include <U8glib.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd1(13,12,7,6,5,4);
LiquidCrystal lcd2(11,10,7,6,5,4);
LiquidCrystal lcd3(9,8,7,6,5,4);
/* FILE: ARD_12864_Graphic_LCD_Module_HCMODU0015_SPI_Example
DATE: 19/07/13
VERSION: 0.1
REVISIONS:
02/07/13 Created version 0.1
This is an example of how to use the 12864 128x64 graphics LCD module (HCMODU0015).
This example sketch uses the U8glib library to output text and graphics to the
screen in SPI mode.
PINOUT:
MODULE` UNO
K (backlight cathode) GND
A (backlight annode) +5V
PSD (SPI Mode) GND (SEE NOTE)
E (SCK) D13
R/W (MOSI) D11
RS (CS) D10
VDD +5V
VSS GND
Connection to the V0 pin (contrast) is not required.
Note: Some versions of this LCD are shipped with the PSB (parallel/serial select) pin
shorted to VDD by a 0 ohm resistor fitted to R9 on the back of the LCD. This fixes the
LCD in parallel mode. If this resistor is fitted and you wish to use the LCD in serial
mode you will either need to move the resistor to D10 or completely remove it and
ground the PSD pin.
You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used for the purpose of premoting or selling products
that directly compete with Hobby Components Ltd's own range of products.
THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER.
U8glib library copywrite notice:
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
Copyright (c) 2012, olikraus@gmail.com
All rights reserved.
*/
/* Include the U8glib library */
#include "U8glib.h"
/* Define the SPI Chip Select pin */
#define CS_PIN 53
/* Create an instance of the library for the 12864 LCD in SPI mode */
U8GLIB_ST7920_128X64_1X u8g(CS_PIN);
void setup()
{
lcd1.begin(16,4);
lcd2.begin(16,4);
lcd3.begin(8,2);
}
/* Main program */
void loop()
{
lcd1.setCursor(0,0);
lcd1.print(" 3 LCD 16X4 ");
delay(100);
lcd2.setCursor(0,0);
lcd2.print(" USING ARDUINO ");
delay(100);
lcd3.setCursor(0,1);
lcd3.print("TRIP ODO");
delay(100);
/* Start of a picture loop */
u8g.firstPage();
/* Keep looping until finished drawing screen */
do
{
/* Set the font */
u8g.setFont(u8g_font_courB14);
/* Display some text */
u8g.drawStr( 20, 26, "WOO HOO");
u8g.drawStr( 8, 46, " IT WORKS");
/* Draw a simple border */
u8g.drawFrame(5,5,117,54);
u8g.drawFrame(3,3,121,58);
}while(u8g.nextPage());
}