Interfacing DG600F Coin Acceptor to Arduino

I helped a kid at the local STEM school with this project. Sparkfun has a good video on getting the coin acceptor programmed, and they have a link to the datasheet which is fairly readable, but I could find no sample code anywhere so I thought I would post what we did for others.

The DG600F Coin Acceptor is available at Sparkfun. It looks like this:

This is a pretty cool little device. It was easy to program in coins and interface to the arduino. The only downside I see is it doesn’t make change. But if you are buying time, that is just fine.

Their project is to use an arduino to determine the dollar amount of coins input into the coin acceptor, then for every $.01, let a user play games on a raspberry Pi for a minute. We decided to let the Arduino count the dollar amount, decide how much time that would buy, then simply raise a pin HIGH when there was time left. That pin would be connected to the RPI and the RPI programmer could read that pin to decide if there is time left to keep playing.

The hardware is connected like this:


We configured the coin acceptor to output serial (moved dip switch 3 to on). It defaults to 4800 baud so we stuck with that and just made sure the code used the same baud rate. We programmed the coin acceptor for .01, .05, .10, and $.25. We tried $.50, but it got caught in the mechanism and decided not to try again.

The following code is quite simple. It reads coin amounts from the coin acceptor and uses that to increase a timer. As long as the timer is > 0, it keeps pin 13 high (which has an LED connected on the board to provide feedback that there is still time).

I wanted to allow the student to be able to use Serial.print to debug the code, so we used the SoftwareSerial library to use pin 2 to receive serial data.

#include <Arduino.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2,3); // RX, TX

int secondsRemaining = 0;
void setup() {
    // Open serial communications and wait for port to open:
    Serial.println("Coin Acceptor Ready!");

    // set the data rate for the SoftwareSerial port

    pinMode(13, OUTPUT);


void loop() {
    int i;
    unsigned long lastMillis = millis();

    while (true) {
        // any input coming from coin acceptor?
        if (mySerial.available()) {
            // read input, which is a 1 byte integer
            // ignore any 255 amounts
            if (i != 255) {
                // increment time based on coin amount
                secondsRemaining = secondsRemaining + i * 60;
                Serial.print("Time Left is ");
                Serial.println(" remaining");
        if ((millis() - lastMillis) > 1000UL) {
            // decrement the time remaining by 1 sec
            lastMillis = millis();
            if (secondsRemaining > 0) {
                secondsRemaining = secondsRemaining - 1;
            if (secondsRemaining > 0)
                digitalWrite(13, HIGH);
                digitalWrite(13, LOW);
            Serial.print("Time Left is ");
            Serial.println(" remaining");
        } // while



This entry was posted in c-arduino and tagged . Bookmark the permalink.

12 Responses to Interfacing DG600F Coin Acceptor to Arduino

  1. Pingback: Using a DG600F Coin Acceptor to Control EmulationStation Gaming Software | Big Dan the Blogging Man

  2. Pingback: Interfacing DG600F coin acceptor module with raspberry-pi | DL-UAT

  3. MB says:

    Hi, I have the exact device above, and an FTDI, as recommended by Sparkfun. I’m a novice to this kind of thing and I’m trying to get the value of coins entered into Microsoft Excel. I wondered if you would be able to help? Thanks!

    • Dan TheMan says:

      Connecting to a PC and making use of it via Excel will be a challenge. You will need to write a program that can read the PC’s serial port where the FTDI cable connects (for example, COM7). Then it will need to somehow send that to excel, perhaps a VB script? Not impossible, but probably not very easy either.

      • Daniel Niño says:

        with c# u can do it. There are libraries to open excel from a c# application and write, save, etc, to manipulate excel.

  4. John says:

    I am trying to build a coin operated device using the Coin accept er you use here. I cant figure out what Library your using. I don’t seem to have the library. Could you tell me which library that is.

  5. John says:

    sorry the Arduino.h library… its been a long night

  6. Josef Mud says:

    would it be possible to change the code so instead of adding time it would add credits? I would use it in Retro Pie emulator like this:

    Coin Acceptor programming:
    Coin values: “1”, “2”, “5”, “10”, “20”, “50”

    send signal if values 5*n (where n=1,2,3,4,5,…, 1000) are detected

    Retro Pie in-game:
    1 credit = “5”
    For example:
    Inserting 1x “5” = ADD CREDIT key is pressed 1x
    Inserting 2x “2” + 1x “1” = ADD CREDIT key is pressed 1x
    Inserting 1x “20” = ADD CREDIT key is pressed 4x, etc.

    I am new to raspberry / arduino platform, so if you can give me direction how to start, I would be grateful!

  7. James says:

    Is the code in this post able to be used under Creative Commons BY-NC-SA 3.0 license?
    License info:

  8. Dan TheMan says:

    Any code I post here is in the public domain to be used however you wish. I’m definitely not going to copyright the loop and handful of if statements found here🙂

    I try to credit code I find elsewhere to the original author and include a link to the source.

    I believe I always point out code that I obtained elsewhere, though I don’t always know exactly where I found it because I might scour 50 websites trying to find a solution to a problem.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s