That would suggest that the coin acceptor is bad not D13. I think you jumped to the Wrong conclusion. It's very rare when only one pin is damaged and not others.
Test D13 by simply connecting/disconnecting a wire to ground.
It's highly unlikely that your circuit damaged D13
As I mentioned powering an Uno through the 5V output pin is not recommended.
But you do have a voltage divider in your schematic.
The one that connects signal to 5-V through the 1K and 10K resistors and connects to D13 at the junction.
When the signal output is 0-V, you are dividing 0 to 5-V at D13. When the signal output is 12-V, you are dividing 12 and 5-V at D13.
When the signal is high, assumed 12-V as there isn’t any information on it, you will exceed the digital pin maximum voltage.
If you go to the link you provided, there’s a sort of datasheet and some additional information about the pulse width. There’s nothing about the amplitude.
You could divide the signal referenced to ground to bring it into a safe maximum voltage or use a voltage translator.
I tried testing the D13 pin with something else, like IR sensor, where using other pins (2-12, 14-19) the IR sensor worked, but in D13, the IR sensor is permanently low which I thought it’s damaged, but yeah dunno if it’s wrong conclusion, I should test it like you said.
If powering an Uno through the 5V output in isn’t recommended, what’d be the better way? (from what I know, using the 12V dc jack isn’t recommended either)
Yes, that's all.
You need to confirm what the maximum voltage is that comes from the SIG pin.
Ideally it's a scope job as it's so fast.
A meter with max and min recording would do.
Alternatively, assume it's 12 volts and play safe.
I can't do the calculation right now, but I'll look at it tomorrow.
It will just be a case of adjusting the the 1K/10K ratio so that the 12 volt high is reduced to 5 volts max.
As a guide, 5K and 5K would give you 6 volts, but it has to be related to the right end of the resistor ladder.
Connect two resistors in series between the SIG output and the common ground.
At the SIG end use a value close to 14K and at the ground end use 10K.
At the junction of the the two resistors, the voltage will be close to 5 volts. Connect this to your digital input.
All this assumes that the SIG pin of your coin device outputs either zero volts or 12 volts
Only if you have many devices connected to the Uno.
What else is connected?
Since you are using 5V there is noneedfor a voltage divider.and it will not work
You must have a pull-up to 5V
If you damaged D13 then it is because you did something else wrong.
The coin output of the TW-130B is an open collector transistor.
The amplitude of the pulse is determined by the circuit that the user connects to the output.
The schematic shown in post #1 should work correctly.
Now that more information has come to light, it's easy.
Working with what the OP provided, not so.
What's the difference then, between Coin signal and the counter output?
The counter is used by the machine operator to tell him how much money he expects to see in the cashbox.
The counter is housed inside the machine, and can't be seen by the general public.
The grey wire connected to pin 4 is an open collector transistor.
A counter with a 12V coil is attached between that pin and the grey wire on pin 1 that has 12V on it.
The open collector transistor conducts briefly to advance the count.
The coin output is used by the machine's electronics to operate the game/vending machine.
This output is selectable between 'normally open' and 'normally closed.
When 'normally open' is selected the output is normally held high by a pullup resistor, and goes low for the duration of the output pulse.
When 'normally closed' is selected, the output is normally low, and goes high for the duration of the output pulse.
From the code that 89jvek showed in post #1, it can be inferred that he has the output set to 'normally open', as he is waiting for the output to go low to detect a coin inserted.
Thanks for clarifying that.
It makes sense now.
The OP just referred to SIG which didn't really make it clear what they were using.
I already use the little Omron counters on several projects.