4 coin piggy bank

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

4 coin piggy bank

Postby Pugsly » Thu Feb 28, 2013 10:40 pm

Extreme noob here. I looked all over google and this forum.

Coding isn't my strong suit at all. In reference to the 1 coin piggy bank, how does the code change or differ when going to the 4 coin version? The original only assumes a single pulse for a single coin type. With the 4 pulses how is that taken into the equation?

On the same note, how do you adjust the code to accommodate the total sum of the coins?

I hope someone can help.....

Extreme thank you's in advance

Pugsly
Pugsly
 
Posts: 3
Joined: Thu Feb 28, 2013 10:32 pm


Re: 4 coin piggy bank

Postby Pugsly » Sat Mar 02, 2013 10:43 am

I saw that, i got that code, but i want to replicate the piggy bank with the lcd display, but using the 4 coin acceptor.


I'm assuming some part of that code will insert after the pulse length.
what i'm having trouble with is how to assume 1, 2, 3, or 4 pulses and than the display showing various amounts to be added. The current code assumes equal values of 25.


Coin values:
1 = .01 (penny)
2 = .05 (nickel)
3 = .1 (dime)
4 = .25 (quarter)
*/

const byte coinValues[4] = {
.01, .05, .1, .25}; //Coin values goes into this array


Where do I fit (adjust if necessary) the above code into the code below?
And again, how do i adjust it to add various amounts for a total?


while (digitalRead(COIN)) {
delay(1);
counter++;
}
Serial.print(counter);
Serial.println(" ms long pulse");

if ((counter > 60) || (counter < 20))
return;

coins++;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" OINK OINK! ");
lcd.setCursor(0,1);
lcd.print("YOU HAVE $");
lcd.print(coins*.25);
lcd.print(" ");
// loop through to flash the LED



(please remember I am totally new at this so please no "do a search stupid or take a class first") I have read getting started with Arduino and other books and i can totally make an led blink!!! :wink:
Pugsly
 
Posts: 3
Joined: Thu Feb 28, 2013 10:32 pm

Re: 4 coin piggy bank

Postby adafruit_support_bill » Sat Mar 02, 2013 8:38 pm

The current code assumes equal values of 25.

Not really, the coin values are stored in the array (lines 11 & 12 of the code)
The array is indexed by the number of pulses (1-4). You can assign whatever values you like to the coins.
Code: Select all
const byte coinValues[4] = {
  5, 10, 20, 100}; //Coin values goes into this array
User avatar
adafruit_support_bill
 
Posts: 16638
Joined: Sat Feb 07, 2009 9:11 am

Re: 4 coin piggy bank

Postby Pugsly » Sun Mar 03, 2013 7:37 am

adafruit_support wrote:
The current code assumes equal values of 25.

Not really, the coin values are stored in the array (lines 11 & 12 of the code)
The array is indexed by the number of pulses (1-4). You can assign whatever values you like to the coins.
Code: Select all
const byte coinValues[4] = {
  5, 10, 20, 100}; //Coin values goes into this array


Great, Ill try it.......well see how it goes.

Thanks
Pugsly
 
Posts: 3
Joined: Thu Feb 28, 2013 10:32 pm


Return to Arduino

Who is online

Users browsing this forum: ArekKindAcere and 17 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [114]

Raspberry Pi[82]
 
FLORA[24]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[12]
Arduino[60]
 
NETduino[14]
 
Android[6]
 
BeagleBone[23]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[39]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[9]


 
Breakout Boards[35]
LCDs & Displays[49]
Components & Parts[70]
Batteries & Power[54]
EL Wire/Tape/Panel[52]
LEDs[112]
 
Wireless[16]
Cables[66]
 
Lasers[6]
Sensors/Parts[147]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[41]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[25]


 
Stickers[41]
 
Skill badges[55]
 
Books[26]
 
Circuit Playground[7]
 
Gift Certificates[4]