Go Down

Topic: access other loop if (Read 231 times) previous topic - next topic


Hi again, i'm trying to access another loop if a condition happen, here the part of the code that i want:

Code: [Select]
case '1':
              //relay pin 22 on
              digitalWrite(22, HIGH);
              Serial.println("Relay 1 on");

and the other loop
Code: [Select]
void relay_onmelody()
     Serial.println("play music on");
     for (int i = 0; i < 3; i++)
       int onnoteDuration = 1000/onnoteDurations[i];
       tone(speaker_pin, relayonmelody[i],onnoteDuration);
       int onpauseBetweenNotes = onnoteDuration * 1.30;

cause i have like 15 case and i don't want to write all the code for the melody every time so if i'm able to access the other loop it will be more simple. with these code i'm note able to compile it.


Code: [Select]
This is not how to call a function.

for loops need ending }, too.


Go Up

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.

shortcuts: alt+s submit/post or alt+p preview