Wednesday 15 April 2015

c++ - Arduino Lily Pad mp3, Loop in Loop in Loop with timing -



c++ - Arduino Lily Pad mp3, Loop in Loop in Loop with timing -

the best way explain problem in codeform.

const int ringerpin = a0; const int offhook = a4; const int onhook = a5; void setup(){ pinmode(ringerpin, output); pinmode(offhook, input); pinmode(onhook, input); randomseed(analogread(0)); } int randcall = random(60000, 3600000); // generate random number between 1 min , 60 min //ring every 1 60 minutes if phone downwards (hookon) , dont ring if phone picked (no hookon) void loop() { if (digitalread(hookon) == high) void loop(){ delay(randcall); //i dont know how allow loop below here run 30 seconds. void loop() { //turn sound off - dont know how to. for(int x = 0; x < 15; x++){ digitalwrite(ringerpin, high); delay(50); digitalwrite(ringerpin, low); delay(80); } delay(2500); } else //play 1 randomly choosen audiofile out of 10 - dont know how } }

i greatful if there can give me suggestions coding problems.? wrote them within code descriptions.

loop() not way create loop. loop() function arduino calls on , on when can.

to create loops, utilize while or for. can think of loop() function beingness body of while(true) loop.

that said, should not utilize loops trying do. there useful function called millis() returns number of milliseconds since device turned on. value overflows every 50 days. need handle that, suggest write loop() function check if plenty time has passed, , supposed to. see this example.

c++ random arduino nested-loops pad

No comments:

Post a Comment