problem in program

Hallo,

I have a problem to put the program into my UNO

sence 27 say’s “stray in program” and I don not know what to do.

I am a Arduino user…not a ICT man…

So please see attachment for the problem and I hope you can help me in simple words.

greetings
Bob
zhtech@zhtech.nl

LiquidCrystal Library.doc (34 KB)

Hello Bob,

Would you be so kind to repost your code as per the following post ?

http://forum.arduino.cc/index.php/topic,148850.0.html

Before copying the program from the Arduino IDE' please do CTRL-T, or use the Auto Format from the Tools menu. That will improve the formatting of your code and will it easier for people to review.

Have you added the library as a ZIP file ? Also, would it be possible to know which version of IDE you are using ?

Cheers

dan

No, he attached a .doc file, with line numbers. Not the best to work with.
Probably the LiquidCrystal.h file is in the wrong place.
Bob, check File:Preferences, see where the path is. In that folder there needs to be a /libraries folder, LiquidCrystal.h needs to be in there.

LiquidCrystal Library - Hello World

 

1 /*

2  Luiquid cristal library - hallo world.

3  In this program, we use 2 switches to make a count increment

4   and decrement

5

6   * LCD RS pin to digital pin 7

7   * LCD Enable pin to digital pin 6

8   * LCD D4 pin to digital pin 5

9   * LCD D5 pin to digital pin 4

10 * LCD D6 pin to digital pin 3

11 * LCD D7 pin to digital pin 2

12 * LCD R/W pin to ground

13 * LCD VSS pin to ground

14 * LCD VCC pin to 5V

15 * 10K potentiometer:

16 *Black wire to Ground

17 *Red wire to VCC

18 *Green wire middle one to VEE

19 */

20 // swtich 1 connected at Pin 8 and other end to GND

21 // switch 2 connected at Pin 9 and other end to GND

22 // Refer Circuit

23

24 int sw1 = 8;  // Connect pin 8 to SW1

25 int sw2 = 9;  // Connect pin 9 to SW2

26 int count = 0;

27 #include <LiquidCrystal.h>              < [color=red]-  stray in program[/color]

28 // initialize the library with the numbers of the interface pins

29 LiquidCrystal lcd(7,6,5,4,3,2);

30

31 void setup() 

32 

33  // set up the LCD's number of columns and rows:

34  lcd.begin(16, 2);

35  // Print a message to the LCD.

36  lcd.print("Up-Down Counter");

37  // Declare Switches as INPUT to Arduino

38  pinMode(sw1,INPUT);

39  pinMode(sw2,INPUT);

40  digitalWrite(sw1,HIGH);

41  digitalWrite(sw2,HIGH);  

42  }

43 

44  void loop() 

45 {

46  if(digitalRead(sw1) == LOW)   // if SW1 is pressed perform action describ

47  ed in loop

48 {

49   count++;                    // Increment Count by 1

50    lcd.setCursor(0, 1);

51    lcd.print(count);

52   delay(400);

53  }

54  if(digitalRead(sw2) == LOW)    // if SW2 is pressed perform action descri

55  bed in loop

56  {

57   count--;                     // Decrement Count by 1

58    if(count < 0)

59      count = 0;

60    lcd.setCursor(0, 1);

61  lcd.print(count);

62    delay(400);

63  }

64  

65 }

I don’t have a standard LCD display, but use an I2C display from Yourduino. I’ve commented out the standard display code and substituted the code for the I2C display and it works fine.

//#include <LiquidCrystal.h>              < [color=red]-  stray in program[/color] ORIGINAL CODE

//#include <Wire.h>  // Comes with Arduino IDE
// Get the LCD I2C Library here: 
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>

/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 16 chars 2 line display
// A FEW use address 0x3F
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

int sw1 = 8;  // Connect pin 8 to SW1

int sw2 = 9;  // Connect pin 9 to SW2

int count = 0;

 // initialize the library with the numbers of the interface pins

// LiquidCrystal lcd(7,6,5,4,3,2);            // ORIGINAL CODE

 void setup() 
{
  // set up the LCD's number of columns and rows:

  lcd.begin(16, 2);

  // Print a message to the LCD.

  lcd.print("Up-Down Counter");

  // Declare Switches as INPUT to Arduino
  pinMode(sw1,INPUT);
  pinMode(sw2,INPUT);
  digitalWrite(sw1,HIGH);
  digitalWrite(sw2,HIGH);  
  }

 

  void loop() 
 {

  if(digitalRead(sw1) == LOW)   // if SW1 is pressed perform action describ
 {
    count++;                    // Increment Count by 1
    lcd.setCursor(0, 1);
    lcd.print(count);
    delay(400);
  }

  if(digitalRead(sw2) == LOW)    // if SW2 is pressed perform action descri
  {
    count--;                     // Decrement Count by 1
    if(count < 0)
      count = 0;
    lcd.setCursor(0, 1);
    lcd.print(count);
    delay(400);
  }
 }