Arduino Uno Loop Question

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Jmarco1955
 
Posts: 12
Joined: Sun May 31, 2015 11:19 am

Arduino Uno Loop Question

Post by Jmarco1955 »

Greetings...In the attached sketch, my loop only runs once and stops...There are no errors compiling...I'm at a loss...Can anyone help?

Thanks in advance...Jim (NOT a programmer)
Attachments

[The extension ino has been deactivated and can no longer be displayed.]


User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Uno Loop Question

Post by adafruit_support_bill »

Does i complete all 14 tracks?

User avatar
Jmarco1955
 
Posts: 12
Joined: Sun May 31, 2015 11:19 am

Re: Arduino Uno Loop Question

Post by Jmarco1955 »

Yes Bill...After it plays track 14 the "rainbow" stops and the loop dies...

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Uno Loop Question

Post by adafruit_support_bill »

The only thing I see that would cause it to stop is if it failed to play one of the files. Your code is designed to hang in a tight loop if any of the tracks fails to start.

What happens if you comment out all of the while(1); statements?

User avatar
Jmarco1955
 
Posts: 12
Joined: Sun May 31, 2015 11:19 am

Re: Arduino Uno Loop Question

Post by Jmarco1955 »

That did it Bill!...I commented out the while (1) statements and it runs great now...

I need to study the example I copied that from...They seemed to be necessary but obviously not...

67 years old...Having fun learning and exploring via Adafruit...Thanks again...Jim

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Uno Loop Question

Post by adafruit_support_bill »

I see that a lot in code for some reason. It is almost never desirable for a program to simply hang without notification at the slightest sign of a problem.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”