My counter

hi every body
i am new in arduino stuff
i finshed my first counter with LCD with uno board
the problem is the counter run ok until 32000
and countdown by them self why???

//code:

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

const int pinA = 11;

int lastA = LOW;

int stateA;

const long DELAY = 100;
long lastATime = 0;

void setup() {
// Print a message to the LCD.
lcd.begin(16,2);
// lcd.clear();
lcd.begin(16,2);
lcd.setCursor(1,0);
lcd.print(“Mohamed Adel”);
lcd.setCursor(2,1);
lcd.print(“01062517522”);
delay(5000);
lcd.clear();
lcd.setCursor(1,0);
delay(1000);
lcd.clear();

pinMode( pinA, INPUT );
pinMode( 13, OUTPUT );

printNumbers(0);

}

int a = 0;
boolean changed = false;

void loop() {
changed = false;

int readA = trippleRead( pinA );

if ( readA == HIGH ){
digitalWrite( 13, HIGH );
} else {
digitalWrite( 13, LOW );
}

if ( readA != lastA && readA == HIGH ) {
a++;
changed = true;
}

if (changed) printNumbers( a );

lastA = readA;

}

void printNumbers( int a ) {
lcd.setCursor(1,0);
lcd.print(" TOTAL : 1000");
lcd.setCursor(1,1);
lcd.print(a);
lcd.setCursor(8,1);
lcd.print(":");
lcd.setCursor(11,1);

lcd.print(a/1000);

}

int trippleRead( int pin ) {

int r1 = digitalRead( pin );
delay(10);
int r2 = digitalRead( pin );
delay(10);
int r3 = digitalRead( pin );

return ( r1 == HIGH && r2 == HIGH && r3 == HIGH ? HIGH : LOW );

}
//end code

An int data type can hold values from -32768 to 32767. An unsigned int can hold 0 to 65535. If you wish to have bigger numbers use the long data type.

http://playground.arduino.cc/Code/DatatypePractices

Please read the "how to use the forum" stickies to see how to format and post code.

thank you
but i am beginner and i don't know where i have to change

thank you for your command

int a = 0;
void printNumbers( int a )

Now read GroundFungus post again.

thank you
really this site is so useful

So, it seems you need to learn about C++ data types.

Here ya go: Variables and types - C++ Tutorials.

sorry every body i still in the problem
the counter count until 32000 and count down can any body modified my code with a new code
thanks

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

const int pinA = 11;

int lastA = LOW;

int stateA;

const long DELAY = 100;
long lastATime = 0;

void setup() {
  // Print a message to the LCD.
   lcd.begin(16,2);
//  lcd.clear();
  lcd.begin(16,2);
   lcd.setCursor(1,0);
   lcd.print("Mohamed Adel");
   lcd.setCursor(2,1);
   lcd.print("01062517522");
   delay(5000);
   lcd.clear();
   lcd.setCursor(1,0); 
  delay(1000);
  lcd.clear();

  pinMode( pinA, INPUT );
  pinMode( 13, OUTPUT );

printNumbers(0);

}

int a = 0;
boolean changed = false;

void loop() {
  changed = false;

  int readA = trippleRead( pinA );
 

  if ( readA == HIGH ){
    digitalWrite( 13, HIGH );
  } else {
    digitalWrite( 13, LOW );
  }

  if ( readA != lastA && readA == HIGH ) {
    a++;
    changed = true;
  }

 
  if (changed) printNumbers( a );

  lastA = readA;
 
}

void printNumbers( int a ) {
  lcd.setCursor(1,0);
   lcd.print(" TOTAL :  1000");
   lcd.setCursor(1,1);
  lcd.print(a);
     lcd.setCursor(8,1);
    lcd.print(":");
       lcd.setCursor(11,1);

      lcd.print(a/1000);



}

int trippleRead( int pin ) {

  int r1 = digitalRead( pin );
  delay(10);
  int r2 = digitalRead( pin );
  delay(10);
  int r3 = digitalRead( pin );

  return ( r1 == HIGH && r2 == HIGH && r3 == HIGH ? HIGH : LOW ); 

}
int a = 0;

To

unsigned long a =0;[
// and
void printNumbers( unsigned long a ) {

There, did you learn anything?

groundfungus:

int a = 0;

To

unsigned long a =0;[

// and
void printNumbers( unsigned long a ) {




There, did you learn anything?

no i don't learn
thank you any way it is not work at all
are you compile it before you speak by that sound "did you learn anything?"

mohamedadel:
no i don't learn
thank you any way it is not work at all
are you compile it before you speak by that sound "did you learn anything?"

What ever groundfungus wrote wont compile, because its not a full code. He is trying to point you to the right direction by pointing some portion of the code.

You might have missed the post #5 by Paul, visit the link and understand variable types.