Music Stream Demo on/off switch pullup

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jerryn
 
Posts: 1868
Joined: Sat Sep 14, 2013 9:05 am

Music Stream Demo on/off switch pullup

Post by jerryn »

I was having some intermittent issues with the on/off switch with the music streamer demo.
Wouldn't it be better to specify the pin used for the on/off switch in the music streamer demo with the PULLUP enabled

Code: Select all

  pinMode(ON_OFF_SWITCH, INPUT_PULLUP);
especially if the switch is not installed and the input is floating.

I also moved it from GPIO04 to GPIO12 to avoid a conflict with the IR sensor demo code.

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

Re: Music Stream Demo on/off switch pullup

Post by adafruit_support_bill »

Please post a link to the tutorial you are referring to.

User avatar
jerryn
 
Posts: 1868
Joined: Sat Sep 14, 2013 9:05 am

Re: Music Stream Demo on/off switch pullup

Post by jerryn »

It was in the sample code for this:
https://learn.adafruit.com/adabox004#internet-radio

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

Re: Music Stream Demo on/off switch pullup

Post by adafruit_support_bill »

The circuit in the guide has the switch wired with one pole to VCC and the other to GND. But if your switch is not installed, the input will float. In that case, enabling the pullup will pull it HIGH by default.

User avatar
jerryn
 
Posts: 1868
Joined: Sat Sep 14, 2013 9:05 am

Re: Music Stream Demo on/off switch pullup

Post by jerryn »

Thanks for confirming this. The reason I mentioned it is that the way the tutorial is written I assumed it was meant to be run at first without the switch or potentiometer, then those could be added if desired.
Here is the full code. Upload this code to your MusicMaker setup and open the serial console. You should see it connect to your network and start playing some music. You will notice that there is a bit of code in there for adding in a potentiometer and on/off switch. We will add these next.
Adding the pullup would cover both cases and possibly avoid some frustration if it did not work.

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

Re: Music Stream Demo on/off switch pullup

Post by adafruit_support_bill »

Thanks for the feedback. I will mention it to the author.

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: Music Stream Demo on/off switch pullup

Post by adafruit2 »

oh yah! fixed now, try it?

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

Return to “AdaBox! Show us what you made!”