Lily Pad mp3, nested loops with timing and play randomly choosen mp3, coding problem
Halo, thank you for ansering anything.. I got the loop loop loop thing now runin..

So its about playing an Audiofile if hookon == LOW ........ check it out :-)

The code now looks like this.

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 (hookon) and dont ring if the phone is picked up (no hookon)
void loop()
{
  if (digitalRead(hookon) == HIGH){
    delay (randCall);
    beginRing = Time.elapsedTime;
    while(Time.elapsedTime - beginRing &lt;= 30000 &amp;&amp; digitalRead(hookon) == HIGH){
      //turn any audio off???
      for(int x = 0; x &lt; 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 50 msec
      }
      delay(2500);
    }
  }
  if(Time.elapsedTime - beginRing &lt;= 30000){
    //play one randomly choosen audiofile out of 10
  }
}


So, now its about to stop any sound if the hookon is HIGH and to play the randomly choosen file 1 out of 10 if the hookon is LOW (its in the code as description...there i need the right comands)