this is what i came up with so far.. i guess next will be the pulse counting... i rather have the machine on hand instead of just coding blindly.. so i shall continue to wait for it to come in.
#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 & config exapander chip
// LCD geometry
const int LCD_COLS = 20;
const int LCD_ROWS = 4;
int Coins = 2; // white wire from coin acceptor
int ResetButton = 3; // hidden inside and resers All counts, no turning back
int MenuButton = 4; // controlls lcd screen
//int Speaker =5; // not being used at this time
// lcd screen pins
int Savings;
int Pennies;
int Nickles;
int Dimes;
int Quarters;
int HalfDollars;
int DollarCoins;
int ResetButtonState = 0;
int MenuButtonState = 0;
void setup() {
// put your setup code here, to run once:
int status;
status = lcd.begin(LCD_COLS, LCD_ROWS);
pinMode(Coins, INPUT);
pinMode(ResetButton, INPUT);
pinMode(MenuButton, INPUT);
//pinMode(Speaker, OUTPUT); // not being used at this time
// if reset button is pressed, reset ALL counts - no turning back
ResetButtonState = digitalRead(ResetButton);
ResetAll();
// if MenuButton is pressed, change lcd accordingly
switch (MenuButton) {
case 1:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Quarters: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 1);
lcd.print("Dimes: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 2);
lcd.print("Nickles: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 3);
lcd.print("Pennies: 0"); // text to the left side and count right side if possible, use commas
delay(3000);
break;
// go back to main loop if menu button is not pressed again for second case
case 2:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Halves: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 1);
lcd.print("Dollar: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 2);
lcd.print(" Total Coins: "); // text to the right side and count left side if possible, use commas
lcd.setCursor(0, 3);
lcd.print("0"); // count right side if possible, USE COMMA FORMAT
delay(3000);
break;
// now go back to main loop, if button is pressed again go back to case 1
}
}
void loop() {
// put your main code here, to run repeatedly:
// i could use a state machine for this, but not going to right now.. easier and smaller coding this way
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" INSERT ");
lcd.setCursor(0, 2);
lcd.print(" CHANGE ");
delay(500);
lcd.clear();
delay(500);
}
void ResetAll() {
int Savings = 0;
int Pennies = 0;
int Nickles = 0;
int Dimes = 0;
int Quarters = 0;
int HalfDollars = 0;
int DollarCoins = 0;
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" SAVINGS ");
lcd.setCursor(0, 2);
lcd.print(" CLEARED ");
delay(500);
lcd.clear();
// now go back to main loop
}