What would I do with a Laser Cutter? Build Simple Robotic Kits to teach people a Hobby that I Love.
Ever wanted to make some money from your projects?
This Instrutable will show you how to Simply interface a coin selector with your Adruino.
And also how to then connect that to your Visual C# Project.
Then it's all up to you and that great idea you have, if it's electronic or a program/game,
The Buck Starts Here.
You will need:
A Coin Selector: There are many different type's, the CH-926 accepts the most amount of coins so thats what I'll be using.
UK Stock, US Stock
Any 12v Power Supply, Batteries or Wall Wart.
An Arduino UNO
Microsoft Visual Express 2010 C#: Free Download, Scroll down until you see the correct option.
Note: Only needed for a coin operated Program, Not electronics Projects.
Let's get Started!
Remove these ads by
Signing UpStep 1: Coin Sampling
It is recommend to sample at least 15 coins of the same type, up to a maximum of 30. Don't feed the same coin through 30 times, it's make the selector to fussy about what it accepts.
A Coin Selector works by comparing the material, weight and size of coins past through it to the samples you provide. If a coin is not reconised it drops out the return slot, if it is reconised the Unit sends out pulse's on the "COIN" line.
So to make it easier for the programming side we use a "greatest common factor" rule.
eg. We'll use the following coins (UK) 5p, 10p, 20p, 50p,& £1, (US) 5c, 10c, 25c, 50c & $1.
All the the coins can be made up with multiple 5p or 5c coins, so we make 1 pulse equal to 5p or 5c.
5p/c = 1 pulse, 10p/c = 2 pulses, 20p = 4 pulses, 25c = 5 pulses, 50p/c = 10 pulses, £/$1 = 20 pulses.
Now, The Setup:
First the switches...
select "NC" by sliding the top switch to the bottom position.
select "FAST" by sliding the bottom switch to the top position.
Power Up the unit with a 12v supply.
1. Hold the "ADD" and "MINUS" buttons down at the same time for about 3 seconds, release and then the letter "A" will appear on the LED display.
2. Press the "SETUP" button once, and the letter "E" will appear. Then use the "ADD" and "MINUS" buttons to choose how many kinds of coins your going to use. Press the "SETUP" button again to finish.
3. The letter "H" will appear. Use the "ADD" and "MINUS"buttons to choose how many sample coins your going to feed it later. Press the"SETUP" button again to finish.
4. The letter "P" will appear. Again use the "ADD" and "MINUS" buttons to choose the amount of output pulses you want. Press the "SETUP" button to finish. Refer to the above example to determine number of pulses.
5. The letter "F" will appear. Using the "ADD" and "MINUS" buttons, choose the accuracy. The value is from 1 to 30, with 1 being the most accurate. I use 10 and it works fine. Again "SETUP" to finish.
You have now setup the first coin, depending on how many coins you selected in step 2, you'll have to repeat Step's 3 to 5 for each one.
The letter "A" will appear when you've setup all the coins. Hold "SETUP" for 3 seconds to finish, the letter "E" will appear.
Finally, switch the unit off and then back on.
Sampling time:
1. Hold the "SETUP" button down for about 3 seconds, release and then the letters "A1" will appear on the LED display. This is your first coin (5p/c)
2. Feed the Coin Selector your sample coins, the LED display will show the amount of coins you've entered. "A1" will appear again when finished.
3. Hold the "SETUP" button down again for about 3 seconds, release and then"A2" will appear, repeat these steps until all coins are sampled.
If your not using all of the coin types available (eg 5 coins of a 6 type coin selector) the unit will ask for samples of a coin type you haven't setup, just hold the "SETUP" button down for 3 secconds of each of the remaining coins.
The Coin Selector restarts itself and is now ready to connect to the Arduino.








































Visit Our Store »
Go Pro Today »




With the available documentation, (and without an oscilloscope on hand), I'm finding it hard to identify what the peak output voltage is from the COIN line, but it's safest to assume it's 12V like the supply in the absence of any other information. Perhaps you have found a data sheet which says otherwise.
But when i attach it to Arduino, it simply doesn't send any signal, any pulses.
The ground of coin acceptor is connected with ground of supply and arduino ground.
The signal with voltimeter is 0.004 and when i insert a coin 0.016 V.
what's wrong with this little toy? Thanks, so sorry for my English.
I've purchased the ch-926 Coin Selector and i've programmed it with 1, 2 and 0.50 €.
Next, i've programmed arduino with sample sketch and it didn't work.
There is a pulse when i switch on the coin selector and another when i try to switch between NC and NO.
Anyway it doesn't send pulses when i insert my coins.
So, i've tested it with "Analog IN" ports and it show me a value between 0.03 and 0.09 with this code:
double sensorValue = analogRead(A0);
double voltage = sensorValue * (500 / 1023.0);
I suspect that my Coin Selector is faulty and it doesn't send my pulses.
How can i solve? Any ideas?
Thanks for advices, Paki
const int coinInt = 0;
//Attach coinInt to Interrupt Pin 0 (Digital Pin 2). Pin 3 = Interrpt Pin 1.
volatile float coinsValue = 0.00;
//Set the coinsValue to a Volatile float
//Volatile as this variable changes any time the Interrupt is triggered
int coinsChange = 0;
//A Coin has been inserted flag
void setup()
{
Serial.begin(9600);
//Start Serial Communication
attachInterrupt(coinInt, coinInserted, RISING);
//If coinInt goes HIGH (a Pulse), call the coinInserted function
//An attachInterrupt will always trigger, even if your using delays
}
void coinInserted()
//The function that is called every time it recieves a pulse
{
coinsValue = coinsValue + 0.05;
//As we set the Pulse to represent 5p or 5c we add this to the coinsValue
coinsChange = 1;
//Flag that there has been a coin inserted
}
void loop()
{
if(coinsChange == 1)
//Check if a coin has been Inserted
{
coinsChange = 0;
//unflag that a coin has been inserted
if(coinsValue >= 0.50)
{
const int led_red = 1; // Output pins for the LEDs
const int led_blue = 2;
const int led_yellow = 3;
const int led_green = 4;
const int buzzer = 5; // Output pin for the buzzer
const int red_button = 9; // Input pins for the buttons
const int blue_button = 10;
const int yellow_button = 11;
const int green_button = 12; // Pin 13 is special - didn't work as planned
long sequence[20]; // Array to hold sequence
int count = 0; // Sequence counter
long input = 5; // Button indicator
int wait = 500; // Variable delay as sequence gets longer
/*
playtone function taken from Oomlout sample
takes a tone variable that is half the period of desired frequency
and a duration in milliseconds
*/
void playtone(int tone, int duration) { <<<<<<*************************************************
for (long i = 0; i < duration * 1000L; i += tone *2) {
digitalWrite(buzzer, HIGH);
delayMicroseconds(tone);
digitalWrite(buzzer, LOW);
delayMicroseconds(tone);
}
}
/*
functions to flash LEDs and play corresponding tones
very simple - turn LED on, play tone for .5s, turn LED off
*/
void flash_red() {
digitalWrite(led_red, HIGH);
playtone(2273,wait); // low A
digitalWrite(led_red, LOW);
}
void flash_blue() {
digitalWrite(led_blue, HIGH);
playtone(1700,wait); // D
digitalWrite(led_blue, LOW);
}
void flash_yellow() {
digitalWrite(led_yellow, HIGH);
playtone(1275,wait); // G
digitalWrite(led_yellow, LOW);
}
void flash_green() {
digitalWrite(led_green, HIGH);
playtone(1136,wait); // high A
digitalWrite(led_green, LOW);
}
// a simple test function to flash all of the LEDs in turn
void runtest() {
flash_red();
flash_green();
flash_yellow();
flash_blue();
}
/* a function to flash the LED corresponding to what is held
in the sequence
*/
void squark(long led) {
switch (led) {
case 0:
flash_red();
break;
case 1:
flash_green();
break;
case 2:
flash_yellow();
break;
case 3:
flash_blue();
break;
}
delay(50);
}
// function to congratulate winning sequence
void congratulate() {
digitalWrite(led_red, HIGH); // turn all LEDs on
digitalWrite(led_green, HIGH);
digitalWrite(led_yellow, HIGH);
digitalWrite(led_blue, HIGH);
playtone(1014,250); // play a jingle
delay(25);
playtone(1014,250);
delay(25);
playtone(1014,250);
delay(25);
playtone(956,500);
delay(25);
playtone(1014,250);
delay(25);
playtone(956,500);
delay(2000);
digitalWrite(led_red, LOW); // turn all LEDs off
digitalWrite(led_green, LOW);
digitalWrite(led_yellow, LOW);
digitalWrite(led_blue, LOW);
resetCount(); // reset sequence
}
// function to reset after winning or losing
void resetCount() {
count = 0;
wait = 500;
}
// function to build and play the sequence
void playSequence() {
sequence[count] = random(4); // add a new value to sequence
for (int i = 0; i < count; i++) { // loop for sequence length
squark(sequence[i]); // flash/beep
}
wait = 500 - (count * 15); // vary delay
count++; // increment sequence length
}
// function to read sequence from player
void readSequence() {
for (int i=1; i < count; i++) { // loop for sequence length
while (input==5){ // wait until button pressed
if (digitalRead(red_button) == LOW) { // Red button
input = 0;
}
if (digitalRead(green_button) == LOW) { // Green button
input = 1;
}
if (digitalRead(yellow_button) == LOW) { // Yellow button
input = 2;
}
if (digitalRead(blue_button) == LOW) { // Blue button
input = 3;
}
}
if (sequence[i-1] == input) { // was it the right button?
squark(input); // flash/buzz
if (i == 20) { // check for correct sequence of 20
congratulate(); // congratulate the winner
}
}
else {
playtone(4545,1000); // low tone for fail
squark(sequence[i-1]); // double flash for the right colour
squark(sequence[i-1]);
resetCount(); // reset sequence
}
input = 5; // reset input
}
}
// standard sketch setup function
void setup() {
pinMode(led_red, OUTPUT); // configure LEDs and buzzer on outputs
pinMode(led_green, OUTPUT);
pinMode(led_yellow, OUTPUT);
pinMode(led_blue, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(red_button, INPUT); // configure buttons on inputs
digitalWrite(red_button, HIGH);// turn on pullup resistors
pinMode(green_button, INPUT);
digitalWrite(green_button, HIGH);
pinMode(yellow_button, INPUT);
digitalWrite(yellow_button, HIGH);
pinMode(blue_button, INPUT);
digitalWrite(blue_button, HIGH);
randomSeed(analogRead(5)); // random seed for sequence generation
//runtest();
}
// standard sketch loop function
void loop() {
playSequence(); // play the sequence
readSequence(); // read the sequence
delay(1000); // wait a sec
}
Serial.println("I'M MAKING MONEY!!!!");
}
}
}
Thanks
Thanks.
Good luck with your project.
A refund option could be mechanical. Coins that pass through the counter are collected in a small bin. The customer makes their selection and the coins are dropped into a bucket. If they don't make a selection and select a refund, the coins are dropped out to a refund cup on the outside of the machine... A small servo could activate the midpoint bin, one direction for keep, another for refund.
http://faz-voce-mesmo.blogspot.pt/2012/09/um-makerbot-serio-um-robot-espanhol.html
Keep in mind that if you want to use this in a public place, most places (at least in the US) you need a license from the city/county/state for a coin operated machine, and fines for not having one are seriously hefty.