Merk (Customer) asked a question.

I get an error message on the serial monitor "Slots must be between 1 and 15"

This error message only appears when I push a button to break a while loop.

When not in the while loop the button works fine, no error message.

Any suggestions?​


    • Merk (Customer)

      The code is several pages long and the problem is now resolved (see below in this thread).

      If you're still interested in it, I will post it when I get back to my office next week.

  • frankb101 (Customer)

    It sounds as though you have a value higher or lower than a valid value for the slot parameter while referencing a particular module.

    • Merk (Customer)

       

       

      The problem is resolved but I don't know why.

       

      The module referenced was correct since there are several input devices on this module that all work fine. The ​push-button attached to this module also worked fine except when it was pushed while the whole system was In a "while" loop. This particular button is a "Home" button that returns the various moving parts of the machine back to their home positions regardless of where in the sequence the machine is at. The while loop is there to have the machine "dwell" in a certain position if all of the while conditions are met (the dwell time set by a potentiometer), and the home button should interrupt that dwell and immediately move the machine back to home.

       

      One of the conditions of this while loop is to check if this button is pushed, if so, break out of the loop.

       

      ​The loop that runs during the "while", checks the state of this button, if it goes from 0 to 1, the while ends.

       

      I changed the code to directly read the input to see if it is HIGH or LOW instead of checking the button State.

       

      This solved the problem. However, when I built a breadboard mock-up in my office prior to implementing it at my client's location, I used an Arduino Mega (I didn't have another P1AM (MKR) board on hand). On the Mega, the button wouldn't break the while loop if

      it was simply reading the button for HIGH or LOW, it had to check for a change of State.​

      For de-bugging the inputs, I added code near the beginning of the Loop to display the state of the various inputs on the serial monitor. All inputs displayed the expected 0 or 1, it was only if the system was running the while loop that the error message appeared, pushing that button. I did not change anything about the Serial.print lines that display the input states, yet now it doesn't display the error message and the home button breaks the while loop.

       

       

      Odd behaviour, possibly some idiosyncrasies of the P100/MKR system. Either way, it all works fine now.

       

      Expand Post