I learned a lot inside thise project. Now i got the last problem to solve.
Best way to explain is in the codedescriptions.
Code descriptions with "???" at the end are the open questions. just two small questions.
const int ringerPin = A0;
//const int offhook = A4;
const int onhook = A5;
double beginRing = -40000;
void setup(){
pinMode(ringerPin, OUTPUT);
//pinMode(offhook, INPUT);
pinMode(onhook, INPUT);
randomSeed(analogRead(0)); // this starts Arduino's random number generator
}
int randCall = random(60000, 3600000); // generate a random number between 1 min and 60 min
//ring every 1 to 60 minutes if the phone is down (onhook, arduino gnd and digitalpin connected) and dont ring if the phone is picked up (no onhook)
void loop()
{
if (digitalRead(onhook) == HIGH){
delay (randCall);
beginRing = Time.elapsedTime;
while(Time.elapsedTime - beginRing <= 30000 && digitalRead(onhook) == HIGH){
//turn audio off
for(int x = 0; x < 15; x++){
digitalWrite(ringerPin, HIGH); // turn the solenoid on (HIGH is the voltage level)
delay(50); // wait for 50 msec
digitalWrite(ringerPin, LOW); // turn the solenoid off by making the voltage LOW
delay(80); // wait for 80 msec
}
delay(2500);
}
}
if(Time.elapsedTime - beginRing <= 30000){
//play one randomly choosen audiofile out of 10
}
}