How to send signal programmable.

Hi, would like to know how can i code this on the pin3, for 3 drop coin? for 50ms pulse width do i have to use delay to do this?

digitalWrite(pin3, LOW);
delay(50); // for 50ms?
digitalWrite(pin3, HIGH);
delay(50); // for 50ms?
digitalWrite(pin3, LOW);
delay(50); // for 50ms?
digitalWrite(pin3, HIGH);
delay(50); // for 50ms?
digitalWrite(pin3, LOW);

do i have to use delay to do this?

No. What that picture is telling you is that you need to notice when the pin goes LOW, and record when that happens. Then, you need to notice when the pin goes HIGH again, and record when that happens. When the pin has gone LOW and then HIGH, you use the recorded times to determine how long the pin was LOW. The interval tells you what kind of coin passed the detector.

It is unlikely that you'll be able to notice when the pin changes state without using an external interrupt pin and an interrupt handler for the FALLING edge and another one, on another pin, for the RISING edge, or one handler on one pin for CHANGE. (In that handler, you'd need to determine if the state of the pin is now LOW (it was a FALLING edge) or HIGH (it was a rising edge).

hi thanks :slight_smile:

actually, i will replace the coin drop machine and will simulate it by sending pulses signal to interface. Thanks

actually, i will replace the coin drop machine and will simulate it by sending pulses signal to interface.

You need to determine if 50ms means 50 milliseconds or 50 microseconds. delay() deals with milliseconds. delayMicroseconds() does not.

No you don't have to use delay() but it would probably be the best solution for this problem. What happened when you tried it?

thanks guys!

MorganS:
No you don’t have to use delay() but it would probably be the best solution for this problem. What happened when you tried it?

not yet :slight_smile: my first time with adruino

PaulS:
You need to determine if 50ms means 50 milliseconds or 50 microseconds. delay() deals with milliseconds. delayMicroseconds() does not.

thanks i think millisecs.

do i need to connect to dc of the interface shown in below? or i can use arduino voltage? please help me out. this is the only missing link for my project, dont know how to send signal... thanks

MorganS:
No you don't have to use delay() but it would probably be the best solution for this problem. What happened when you tried it?

are the delay use for pulse width?