Memorial day is 05/25/2015 – Orders will ship out on May 26th. There will not be any deliveries or shipping on Monday. Any order placed after 11am ET on Friday May 22nd will not start to ship out until Tuesday May 26th.

Donkey Kong modded to take pennies, nickles and dimes
Moderators: adafruit_support_bill, adafruit

Donkey Kong modded to take pennies, nickles and dimes

by blackie on Thu Nov 21, 2013 10:27 am

I used a programmable coin acceptor, a trinket and relay to mod my Donkey Kong cab so it will take pennies, nickles and dimes.

Image

Image


The Adafruit Programmable Piggy Bank code only needed a few small changes.
Code: Select all | TOGGLE FULL SIZE
/*********************
* connect the COIN wire to digital 2
* set the side switches to "FAST" "NC"
*Program so penny = 1 pulse
*            nickle = 5 pulses
*            dime = 10 pulses
*            quarter/token = 25 pulses
*
*connect the RELAY wire to pin 3
**********************/


// attach coin wire to pin 2
#define COIN 2
// attach relay wire to pin 3
#define RELAY 3

//This will be used to keep track of coin value
int value = 0;

void setup() {
  pinMode(RELAY, OUTPUT);
  pinMode(COIN, INPUT);
  digitalWrite(COIN, HIGH); // pull up
}

void loop() {


  // while the coin pin is low (no coin detected), do nothing
  while (! digitalRead(COIN)) {
    delay(1);
  }

  // while the pin is high, we'll track the length with a counter
  uint8_t counter = 0;
 
  while (digitalRead(COIN)) {
       delay(1);
        counter++;
    }
 
  if ((counter > 60) || (counter < 20))
      return;
 // add to value for each good pulse counted.     
  value++;
     
 // for every 25 pulses, turn relay on/off     
   if (value >= 25)
      addcoin();
       
 }

void addcoin() {
    digitalWrite(RELAY, HIGH);   // turn the RELAY on (HIGH is the voltage level)
    value = value - 25;        // subtrack 25 from value
    delay(50);               // wait for a little
    digitalWrite(RELAY, LOW);
}
blackie
 
Posts: 3
Joined: Fri Aug 09, 2013 11:13 am

Re: Donkey Kong modded to take pennies, nickles and dimes

by adafruit_support_bill on Thu Nov 21, 2013 10:49 am

Awesome! Thanks for the post! :D

adafruit_support_bill
 
Posts: 37492
Joined: Sat Feb 07, 2009 10:11 am