Pages: [1]   Go Down
Author Topic: access other loop if  (Read 182 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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


and the other loop
Code:
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;
       delay(onpauseBetweenNotes);
       noTone(speaker_pin);
}

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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 548
Posts: 46019
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
              relay_onmelody;
This is not how to call a function.

for loops need ending }, too.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Pauls, that works.
Logged

Pages: [1]   Go Up
Jump to: