Pulse Reading from Coin slot to Arduino

THANK YOU SO MUCH for the suggestions/advice/comments.
This is the code now:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 6, 5, 4, 3);
volatile int coins = 0;

void setup()
{
  lcd.begin(16, 2);
  pinMode (2,INPUT_PULLUP);
  attachInterrupt(0, coinInserted, FALLING);
}
void coinInserted()
{
  coins = coins + 1;
}
void loop()
{
  lcd.setCursor(1,0);
  lcd.print(coins);
}

On the LCD display, when i turn on the Arduino and the Coin Slot, it displays 1 and not 0 so i assume it already read a pulse when turned on, but still it counts the way i need it to count. It doesn't count up continuously anymore, and counts up respectively to what coin is inserted. Still starting from 0 and not 1 would be a bit more of a convenience to me than finding a way to get rid of the unnecessary 1 on start. Thanks for the Help! XD

1 Like