What are you going to use to initiate a ringing sequence, and when should it stop?
Like "ring in the pattern as long as an input is HIGH"
OR
"ring in the pattern for N number of rings"
Either at this point is a very simple extension of your already success, although to do it in a simple way would compromise a future ability to do more sophisticated things.
If it's just (just, haha, no value judgment, I like the art and science or prop-ology or whatever you call it)
If it is a stage prop, it probably only needs to do one thing reliably and simply.
Do you need to be able to STOP the ringing when an actor lifts the handset? Could that come in the middle between a Ding and an Aling?
We close, just a few pesky dets, THX.
Wouldn't mind seeing your code when you "tried to make the Ring a function and try and turn the function off and on, but that didn’t work...", we could prolly tell you where you went wrong.
To clarify, when it comes to the phone ring begining on cue, and the phone stopping ringing when answered, so far i am not worried about that, i just want to make it sound like an actual telephone ring at the moment.
In the future, I am going to try and get the handset switch involved, but that is a lot further down the track!!
Would you recommend I change to digitalWrite? I can do that.
I was intending on writing my delay() in milliseconds, i will avoid having unnessary zeros. So if i stick to delay(100) that would mean delay for 100ms?
Obvsly this rings forever. Adding a hook switch won't be a giant leap for a man. Or woman.
I suggest thinking about "it rings as long as an input says to, and it will always Aling if it Dinged, that is to say it can't be ceased between the two parts of each thing coming along every two seconds.
@arkwent2sea published a bit of code for a ringing sound
void loop() {
// the pattern and frequency
analogWrite(buzzer, 500); // the DING-a-ling of the ring**
delay(0100);
analogWrite (buzzer, 580); // the ding-a-LING of the ring**
delay(0100);
}
And assured us that it worked.
I had a few questions about that, but I never argue against success, so I let those questions be for the moment.
I did not notice the octal constants! But that's OK, just means the OP should use 64 (as noted) if the sound is satisfactory, or 100 if the timing is important. Certainly dealing with decimal values is less tricky, at least for me.
and a recommendation to use digitalWrite, and then there is
I have tested a shower theory: At least on the UNO, analogWrite will use only the lower 8 bits, so the OP's 500 and 580 are the same as 244 and 68 in decimal respectivelyl, and would be more obvious as points of departure for tinkering experimentation. So that should be "fixed" in the code.
As always and especially when multiple radices are involved, check my calculations!
The analogWrite frequency I measure is fixed and 976 Hz. The two tones are coming from the duty cycle of analogWrite's PWM mechanism. This raises questions about what the transducer in the telephone really is... again, I do not argue with success, but I am curious about it.
Nice! I may have to do that to one of the old telephones rotting carefully stored in the basement.