Devices & Components
Arduino Mega 2560 Rev3
Standard LCD - 16x2 White on Blue
Infrared led pair tx and rx
Software & Tools
Arduino IDE
Project description
Code
coin detector counter and amount counter
csharp
1/* 2 COIN DETECTOR amount counter USING INTERRUPT 3 DETEECT THE 4 COIN USING INFRARED LED 5 INTERRUPT PINS ARE CONNECTED TO THE CATHODE OF IR Recivers 6 7 USING ARDUINO MEGA 2560 8*/ 9 10#include <LiquidCrystal.h> 11 12 13LiquidCrystal 14 lcd(30, 32, 34, 31, 33, 35, 37); 15const byte interruptPin1 = 21; 16const byte 17 interruptPin2 = 18; 18const byte interruptPin3 = 19; 19const byte interruptPin4 20 = 20; 21const byte interruptPin5 = 3; 22volatile int value10 = 0; 23volatile 24 int value5 = 0; 25volatile int value1 = 0; 26volatile int valueswitch = 0; 27volatile 28 int countOne = 0 ; 29volatile int countFive = 0; 30volatile int countTen = 0; 31volatile 32 int TOTAL=0; 33void setup() { 34 pinMode(interruptPin1, INPUT_PULLUP); 35 pinMode(interruptPin2, 36 INPUT_PULLUP); 37 pinMode(interruptPin3, INPUT_PULLUP); 38 pinMode(interruptPin4, 39 INPUT_PULLUP); 40 pinMode(interruptPin5, INPUT_PULLUP); 41 attachInterrupt(digitalPinToInterrupt(interruptPin1), 42 coinOne , RISING); 43 attachInterrupt(digitalPinToInterrupt(interruptPin2), coinFive 44 , RISING); 45 attachInterrupt(digitalPinToInterrupt(interruptPin3), coinTen , 46 RISING); 47 attachInterrupt(digitalPinToInterrupt(interruptPin4), show_1_5, RISING); 48 49 attachInterrupt(digitalPinToInterrupt(interruptPin5), show_10, RISING); 50 lcd.begin(16, 51 2); 52 53 lcd.print("COIN DETECTOR &"); 54 lcd.setCursor(1, 1); 55 lcd.print("AMOUNT 56 COUNT"); 57 delay(1200); 58 delay(1200); 59 delay(1200); 60 61 lcd.begin(16, 62 2); 63 lcd.print("INSERT THE COIN"); 64 65 66 Serial.begin(9600); 67 Serial.println(" 68 "); 69 Serial.print("COIN DETECTOR , SORT & AMOUNT COUNTER "); 70} 71 72void 73 loop() { 74 75 76 delay(2000); 77 lcd.begin(16, 2); 78 lcd.print("INSERT 79 THE COIN"); 80 81 82} 83 84/* 85 86 INTERRUPT SERVICE ROUTINE 87 88*/ 89 90void 91 coinTen() { 92 countTen++; 93 value10 = (countTen * 10); 94 Serial.println("\ 95"); 96 97 Serial.println(" 10Rs coin = \ "); 98 Serial.print(value10); 99 Serial.print("Rs"); 100 101 Serial.println("\ 102"); 103 104 105} 106void coinFive() { 107 countFive++; 108 109 value5 = (countFive * 5); 110 Serial.println("\ 111"); 112 Serial.println(" 113 5Rs coin = \ "); 114 Serial.print(value5); 115 Serial.print("Rs"); 116 117} 118 119void 120 coinOne() { 121 countOne++; 122 value1 = (countOne); 123 Serial.println("\ 124"); 125 126 Serial.println(" 1Rs coin = \ "); 127 Serial.print(value1); 128 Serial.print("Rs"); 129} 130void 131 show_1_5() 132{ 133 Serial.println("\ 134"); 135 Serial.println("Number of 1Rs 136 coins = \ "); 137 Serial.print(countOne); 138 Serial.println("\ 139"); 140 141 Serial.println("TOTAL 1Rs COINS = \ "); 142 Serial.print(value1); 143 Serial.print("Rs"); 144 145 Serial.println("\ 146"); 147 Serial.println("Number of 5Rs coins = \ "); 148 149 Serial.print(countFive); 150 Serial.println("\ 151"); 152 Serial.println("TOTAL 153 Rs COINS = \ "); 154 Serial.print(value5); 155 Serial.print("Rs"); 156 //coin 157 of one Rs 158 lcd.begin(16, 2); 159 lcd.print("1Rs coin= "); 160 lcd.setCursor(11, 161 0); 162 lcd.print(value1); 163 // coin of five Rs 164 lcd.setCursor(0, 1); 165 166 lcd.print("5Rs coin ="); 167 lcd.setCursor(11, 1); 168 lcd.print(value5); 169 170} 171void 172 show_10() 173{ 174 Serial.println("\ 175"); 176 Serial.println("Number of 10Rs 177 coins = \ "); 178 Serial.print(countTen); 179 Serial.println("\ 180"); 181 182 Serial.println("TOTAL 10Rs COINS = \ "); 183 Serial.print(value10); 184 185 Serial.print("Rs"); 186 //coin of 10Rs 187 lcd.begin(16, 2); 188 lcd.print("1Rs 189 coin= "); 190 lcd.setCursor(11, 0); 191 lcd.print(value10); 192 //TOTAL AMOUNT 193 194 TOTAL=(value1+value5+value10); 195 lcd.setCursor(0, 1); 196 lcd.print("TOTAL 197 ="); 198 lcd.setCursor(11, 1); 199 lcd.print(TOTAL); 200 Serial.println("\ 201"); 202 203 Serial.println("TOTAL AMOUNT = \ "); 204 Serial.print(TOTAL); 205 Serial.print("Rs"); 206} 207
Downloadable files
coin detector counter and amount counter
coin detector counter and amount counter

coin detector counter and amount counter
coin detector counter and amount counter

coin counter and amount counter
coin counter and amount counter

coin counter and amount counter
coin counter and amount counter

Comments
Only logged in users can leave comments