Money Counter - Coin Detector and Amount by Using Arduino

Programming, Tutorial, Coding, New Design, and/or any project for your Arduino and Raspberry Pi can post your topic /suggestion here.
User avatar
dondon pramis
Inventor
Inventor
Contact:
Location: Philippines
Posts: 55
Joined: Sun Feb 12, 2017 8:28 am

Money Counter - Coin Detector and Amount by Using Arduino

Tue Mar 12, 2019 5:49 pm

Coin counter and amount counter is when coin inserted at first it sorted through the slider and holes the IR led sensors then sense the coin and after signal is send to Arduino of that sense coin and further calculation are done and displayed on lcd 16x2 and serial monitor.

Hardware components

Arduino Mega 2560 & Genuino Mega 2560
Adafruit Standard LCD - 16x2 White on Blue
Infrared led pair tx and rx
maincoin_detector.jpg
Here is the Code for this Project:

Code: Select all

/*
  COIN DETECTOR
  DETECT THE COIN USING INFRARED LED
  USING ARDUINO MEGA 2560
*/

#include <LiquidCrystal.h>
LiquidCrystal lcd(30, 32, 34, 31, 33, 35, 37);
const byte interruptPin1 = 21;
const byte interruptPin2 = 18;
const byte interruptPin3 = 19;
const byte interruptPin4 = 20;
const byte interruptPin5 = 3;
volatile int value10 = 0;
volatile int value5 = 0;
volatile int value1 = 0;
volatile int valueswitch = 0;
volatile int countOne = 0 ;
volatile int countFive = 0;
volatile int countTen = 0;
volatile int TOTAL=0;
void setup() {
  pinMode(interruptPin1, INPUT_PULLUP);
  pinMode(interruptPin2, INPUT_PULLUP);
  pinMode(interruptPin3, INPUT_PULLUP);
  pinMode(interruptPin4, INPUT_PULLUP);
  pinMode(interruptPin5, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin1), coinOne , RISING);
  attachInterrupt(digitalPinToInterrupt(interruptPin2), coinFive , RISING);
  attachInterrupt(digitalPinToInterrupt(interruptPin3), coinTen , RISING);
  attachInterrupt(digitalPinToInterrupt(interruptPin4), show_1_5, RISING);
  attachInterrupt(digitalPinToInterrupt(interruptPin5), show_10, RISING);
  lcd.begin(16, 2);
  
  lcd.print("COIN DETECTOR &");
  lcd.setCursor(1, 1);
  lcd.print("AMOUNT COUNT");
  delay(1200);
  delay(1200);
  delay(1200);
  lcd.begin(16, 2);
  lcd.print("INSERT COIN");
  Serial.begin(9600);
  Serial.println(" ");
  Serial.print("COIN DETECTOR & AMOUNT COUNTER ");
}
void loop() {
  delay(2000);
  lcd.begin(16, 2);
  lcd.print("INSERT COIN");
}
/*
  INTERRUPT SERVICE ROUTINE
*/
void coinTen() {
  countTen++;
  value10 = (countTen * 10);
  Serial.println("\n");
  Serial.println(" 10$ coin = \r ");
  Serial.print(value10);
  Serial.print("$");
  Serial.println("\n");

}
void coinFive() {
  countFive++;
  value5 = (countFive * 5);
  Serial.println("\n");
  Serial.println(" 5$ coin = \r ");
  Serial.print(value5);
  Serial.print("$");
}
void coinOne() {
  countOne++;
  value1 = (countOne);
  Serial.println("\n");
  Serial.println(" 1$ coin = \r ");
  Serial.print(value1);
  Serial.print("$");
}
void show_1_5()
{
  Serial.println("\n");
  Serial.println("Number of 1$ coins =  \r ");
  Serial.print(countOne);
  Serial.println("\n");
  Serial.println("TOTAL 1$ COINS =  \r ");
  Serial.print(value1);
  Serial.print("$");
  Serial.println("\n");
  Serial.println("Number of 5$ coins =  \r ");
  Serial.print(countFive);
  Serial.println("\n");
  Serial.println("TOTAL US Dollar COINS =  \r ");
  Serial.print(value5);
  Serial.print("$");
  //coin of one $
  lcd.begin(16, 2);
  lcd.print("1$ coin= ");
  lcd.setCursor(11, 0);
  lcd.print(value1);
  // coin of five $
  lcd.setCursor(0, 1);
  lcd.print("5$ coin =");
  lcd.setCursor(11, 1);
  lcd.print(value5);

}
void show_10()
{
  Serial.println("\n");
  Serial.println("Number of 10$ coins =  \r ");
  Serial.print(countTen);
  Serial.println("\n");
  Serial.println("TOTAL 10$ COINS =  \r ");
  Serial.print(value10);
  Serial.print("$");
  //coin of 10$
  lcd.begin(16, 2);
  lcd.print("1$ coin= "); 
  lcd.setCursor(11, 0);
  lcd.print(value10);
  //TOTAL AMOUNT
  TOTAL=(value1+value5+value10);
  lcd.setCursor(0, 1);
  lcd.print("TOTAL =");
  lcd.setCursor(11, 1);
  lcd.print(TOTAL);
   Serial.println("\n");
  Serial.println("TOTAL AMOUNT =  \r ");
  Serial.print(TOTAL);
  Serial.print("$");
}



Return to “ARDUINO AND RASPBERRY PI”

Links

In total there are 2 users online :: 1 registered, 0 hidden and 1 guest
Registered users: Google [Bot]
Most users ever online was 162 on Fri Dec 06, 2019 8:39 pm
Total posts 537
Total topics 415
Total members 73
Our newest member Kelly
No birthdays today