I connected coin acceptor's white-wire(signal pulse) to arduino's pin 0, there is LED blinking on it when I insert a coin.. number of blinks are depending on the currency I inserted, question is how could I print the number of blinks/pulses on the arduino serial monitor?.. I tried this code but there's no output when I'm inserting several coins
TIA
coin acceptor: e-Gizmo Technical Blog: Multi-coin Acceptor Debugged
The reason is because you are treating your case values as binary but the compiler expects them to be ints. As you have it, the second coin needs to read one hundred and one pulses! (BTW, 10 decimal is 1010 binary.) Although you could write each case in binary (e.g., case 0b1010:), I would change it to:
switch (NewCoinInserted) {
case 1:
Serial.println("1php inserted");
NewCoinInserted = 0;
break;
case 5:
Serial.println("5php inserted");
NewCoinInserted = 0;
break;
case 10:
Serial.println("10php inserted");
NewCoinInserted = 0;
break;
Finally, I think you need NewCoinInserted to maintain a running total of the coins entered, unless it takes less than 200 ms for all the pulses to arrive. That is, it would seem to me that each coin sends a pulse, so NewCoinInserted would never get larger than 1. Near the top of loop(), should it be:
econjack:
The reason is because you are treating your case values as binary but the compiler expects them to be ints. As you have it, the second coin needs to read one hundred and one pulses! (BTW, 10 decimal is 1010 binary.) Although you could write each case in binary (e.g., case 0b1010:), I would change it to:
switch (NewCoinInserted) {
case 1:
Serial.println("1php inserted");
NewCoinInserted = 0;
break;
case 5:
Serial.println("5php inserted");
NewCoinInserted = 0;
break;
case 10:
Serial.println("10php inserted");
NewCoinInserted = 0;
break;
Finally, I think you need *NewCoinInserted* to maintain a running total of the coins entered, unless it takes less than 200 ms for all the pulses to arrive. That is, it would seem to me that each coin sends a pulse, so *NewCoinInserted* would never get larger than 1. Near the top of *loop()*, should it be:
NewCoinInserted += CoinPulseCount;
I changed the datatype to int and made 101 to 5 & 1010 to 10
still no output :(
Rather than a joke.
The data type and the numeric value you type in
are two different things.
5 is decimal
B101 is 5 in binary
0x05 is 5 in Hex
Do be careful, the number 015 is not the same as decimal 15.
For some reason C interprets the leading 0 as meaning octal
( possibly because octal was convenient on the computers C
was first implemented on ).
Dwight