Why won't this work?

Hi, everyone. Just an old guy here trying to learn new thing.
I have an Ardunio Uno, a 20x4 lcd display and thought it would be good starting point to run one of the many 'hello' sketches to get my feet we.

So, I downloaded this bit of code:

//Written by Nick Koumaris
//info@educ8s.tv
//educ8s.tv
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
void setup()
{
lcd.begin(20,4); // Initialize LCD
lcd.setCursor(3,0); // Set the cursor at the 4th column and 1st row
lcd.print("Hello YouTube!");
lcd.setCursor(8,1); // Set the cursor at the 9th column and 2nd row
lcd.print("");
lcd.setCursor(0,2); // Set the cursor at the 1st column and 3rd row
lcd.print("This is a demo text");
lcd.setCursor(8,3); // Set the cursor at the 9th column and 4th row
lcd.print("
");
}
void loop()
{

}

sure seems simple enough doesn't it? Well it won't compile.

I get a ""POSISTIVE" was not declared in this scope.

I get the same result if I run the IDE on a WIN10 or WIN11 or Mac OS operating system.

Will someone please show me what is wrong with this script?

Error. The entire error is pasted below:

Arduino: 1.8.19 (Mac OS X), Board: "Arduino Nano, ATmega328P"

sketch_jan22a:6:53: error: 'POSITIVE' was not declared in this scope
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
^~~~~~~~
/Users/prosolar/Desktop/ardunio projects/sketch_jan22a/sketch_jan22a.ino: In function 'void setup()':
sketch_jan22a:9:17: error: no matching function for call to 'LiquidCrystal_I2C::begin(int, int)'
lcd.begin(20,4); // Initialize LCD
^
In file included from /Users/prosolar/Desktop/ardunio projects/sketch_jan22a/sketch_jan22a.ino:5:0:
/Users/prosolar/Documents/Arduino/libraries/Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note: candidate: void LiquidCrystal_I2C::begin()
void begin();
^~~~~
/Users/prosolar/Documents/Arduino/libraries/Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note: candidate expects 0 arguments, 2 provided
Multiple libraries were found for "LiquidCrystal_I2C.h"
Used: /Users/prosolar/Documents/Arduino/libraries/Arduino-LiquidCrystal-I2C-library-master
Not used: /Users/prosolar/Documents/Arduino/libraries/NewliquidCrystal
exit status 1
'POSITIVE' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

1 Like

This should be moved to a more suitable category.

I wasn't able to locate that button. I'll look closer next time.

You should copy/paste the actual error in a code block. By "interpreting" the error, you now created an error in the error.

You have mismatched versions of code and library. You can either read why the code is not right in the library example, or step-back the library until the code compiles.

You had an I2C LCD working back in 2017 on a Nano.
What code were you using then?

I HIGHLY recommend using Bill Perry's hd44780_I2C Library.
Install the below library through Library Manager and upload the below example code.

https://docs.arduino.cc/libraries/hd44780/

// vi:ts=4
// ----------------------------------------------------------------------------
// HelloWorld - simple demonstration of lcd
// Created by Bill Perry 2016-07-02 **Modified**
// bperrybap@opensource.billsworld.billandterrie.com
//
// This example code is unlicensed and is released into the public domain
// ----------------------------------------------------------------------------
//
// This sketch is for LCDs with PCF8574 or MCP23008 chip based backpacks
// WARNING:
//	Use caution when using 3v only processors like arm and ESP8266 processors
//	when interfacing with 5v modules as not doing proper level shifting or
//	incorrectly hooking things up can damage the processor.
//
// Sketch prints "Hello, World!" & "Seconds xx" on the lcd
//
// If initialization of the LCD fails and the arduino supports a built in LED,
// the sketch will simply blink the built in LED.
//
// NOTE:
//	If the sketch fails to produce the expected results, or blinks the LED,
//	run the included I2CexpDiag sketch to test the i2c signals and the LCD.
//
// ----------------------------------------------------------------------------
// LiquidCrystal compability:
// Since hd44780 is LiquidCrystal API compatible, most existing LiquidCrystal
// sketches should work with hd44780 hd44780_I2Cexp i/o class once the
// includes are changed to use hd44780 and the lcd object constructor is
// changed to use the hd44780_I2Cexp i/o class.

#include <Wire.h>
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header

hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip

// If you wish to use an i/o expander at a specific address, you can specify the
// i2c address and let the library auto configure it. If you don't specify
// the address, or use an address of zero, the library will search for the
// i2c address of the device.
// hd44780_I2Cexp lcd(i2c_address); // specify a specific i2c address
//
// It is also possible to create multiple/seperate lcd objects
// and the library can still automatically locate them.
// Example:
// hd4480_I2Cexp lcd1;
// hd4480_I2Cexp lcd2;
// The individual lcds would be referenced as lcd1 and lcd2
// i.e. lcd1.home() or lcd2.clear()
//
// It is also possible to specify the i2c address
// when declaring the lcd object.
// Example:
// hd44780_I2Cexp lcd1(0x20);
// hd44780_I2Cexp lcd2(0x27);
// This ensures that each each lcd object is assigned to a specific
// lcd device rather than letting the library automatically asign it.

// LCD geometry
const int LCD_COLS = 20;
const int LCD_ROWS = 4;

void setup()
{
  int status;

  // initialize LCD with number of columns and rows:
  // hd44780 returns a status from begin() that can be used
  // to determine if initalization failed.
  // the actual status codes are defined in <hd44780.h>
  // See the values RV_XXXX
  //
  // looking at the return status from begin() is optional
  // it is being done here to provide feedback should there be an issue
  //
  // note:
  //	begin() will automatically turn on the backlight
  //
  status = lcd.begin(LCD_COLS, LCD_ROWS);
  if (status) // non zero status means it was unsuccesful
  {
    // hd44780 has a fatalError() routine that blinks an led if possible
    // begin() failed so blink error code using the onboard LED if possible
    hd44780::fatalError(status); // does not return
  }

  // initalization was successful, the backlight should be on now

  // Print a message to the LCD
  lcd.print("Hello, World!");
  lcd.setCursor(0, 2);
  lcd.print("Seconds ");
}

void loop()
{
  static unsigned long lcdTimer = 0;
  unsigned long lcdInterval = 500;  // update 2 times per second
  if (millis() - lcdTimer >= lcdInterval)
  {
    lcdTimer = millis();
    unsigned long sec = lcdTimer / 1000;
    lcd.setCursor(8, 2);
    lcd.print("       "); // overwrite old data
    lcd.setCursor(8, 2);  // reset the cursor
    lcd.print(sec);
  }
}
1 Like

Hi, @qrper

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Does your LCD have I2C connectivity?

Can you post some images of your project?
So we can see your component layout.

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

Yup! That's the kicker. I can get the lcd to work on some of the old skeches, but none of the newer ones. I've changed computer in that time frame though. The one I used in '17 was a win 7 pro

Hi, tom.

The wiring is dead simple, +5 from the UNO to the LCD, rec and tx into the correct pins of the display's I2c adapter.

You mean SDA and SCL..
It looks like you are possibly using the wrong I2C LCD library.

Unfortunately there are a few with the same name.

Tom.... :smiley: :+1: :coffee: :australia:

Yes, Tom, the SDA and SCL.... I'm fighting a nasty cold and my thinking is a bit slow.

It appears you are trying to use the NewLiquidCrystal library, or a derivative there of.

2112 edison

Well poop! That worked! Played around a bit with the code and got one of the 'hello' programs to work.

The plot thickens...

This is the original 2018 project that's been sitting idle all these years.

IT's a remote swtich, the port selected is measure, and the result is fed into the ardunio. Depending on the voltage returned, will show what port is selected (and what transceiver for that port)

Currently, and I don't know of any other way of doing it, the transceivers have to be hard coded into the sketch.

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