Adrduino Counter with lcd Display
I made a small device that has 3 independent counters which are shown on a lcd-display. The device uses an arduino and has 3 buttons on the front that are debounced in software and used to increment a variable. The variables are printed on a 1x16 char lcd-display.
the red switch on the side is a power-switch.

i really like the "frankenstein"-look of the eclosure :-)
i also made some sort of a "schematic". scroll down to see the arduino sketch i'm using

arduino sketch:
#include <LiquidCrystal.h>
LiquidCrystal lcd(6, 7, 8, 2, 3, 4, 5);
const int pinA = 9;
const int pinB = 10;
const int pinC = 11;
int lastA = LOW;
int lastB = LOW;
int lastC = LOW;
int stateA;
int stateB;
int stateC;
const long DELAY = 100;
long lastATime = 0;
long lastBTime = 0;
long lastCTime = 0;
void setup() {
// Print a message to the LCD.
lcd.clear();
lcd.setCursor(0,0);
lcd.print("hello, w");
lcd.setCursor( 0, 1);
lcd.print("orld!");
delay(1000);
lcd.clear();
pinMode( pinA, INPUT );
pinMode( pinB, INPUT );
pinMode( pinC, INPUT );
pinMode( 13, OUTPUT );
printNumbers(0, 0, 0);
}
int a, b, c = 0;
boolean changed = false;
void loop() {
changed = false;
int readA = trippleRead( pinA );
int readB = trippleRead( pinB );
int readC = trippleRead( pinC );
if ( readA == HIGH || readB == HIGH || readC == HIGH ) {
digitalWrite( 13, HIGH );
} else {
digitalWrite( 13, LOW );
}
if ( readA != lastA && readA == HIGH ) {
a++;
changed = true;
}
if ( readB != lastB && readB == HIGH ) {
b++;
changed = true;
}
if ( readC != lastC && readC == HIGH ) {
c++;
changed = true;
}
if (changed) printNumbers( a, b, c );
lastA = readA;
lastB = readB;
lastC = readC;
}
void printNumbers( int a, int b, int c ) {
lcd.setCursor(0,0);
lcd.print(a);
lcd.setCursor(4,0);
lcd.print(b);
lcd.setCursor(0, 1);
lcd.print(c);
}
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 );
}

