Flora can't read D11 button press

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
wingnut59
 
Posts: 15
Joined: Tue Mar 05, 2013 11:55 pm

Flora can't read D11 button press

Post by wingnut59 »

I have 3 buttons connected to D09, D10, D11 to read one of 7 states I want my project to be in. I can read from D09 and D10 just fine, can't seem to read from D11. The code from my project where the buttons are setup is as follows.

#define BUTTON1_PIN 9
#define BUTTON2_PIN 10
#define BUTTON3_PIN 11
#define BUTTON_DELAY 20

void setup() {
pinMode(BUTTON1_PIN, INPUT);
digitalWrite(BUTTON1_PIN,HIGH); // pull-up
pinMode(BUTTON2_PIN, INPUT);
digitalWrite(BUTTON2_PIN,HIGH); // pull-up
pinMode(BUTTON3_PIN, INPUT);
digitalWrite(BUTTON3_PIN,HIGH); // pull-up
Serial.begin(9600);
strip.begin();

// Update the strip, to start they are all 'off'
int i;
for (i=0;i<strip.numPixels(); i++){
strip.setPixelColor(i,Color(225, 128, 0));
}
strip.show();
}

// then the area where I read the buttons.

int button_pressed = 0;
// Some example procedures showing how to display to the pixels
boolean button1_pressed = handle_button1();
if (button1_pressed){
button_pressed += 1;
}
boolean button2_pressed = handle_button2();
if (button2_pressed) {
button_pressed +=2;
}
boolean button3_pressed = handle_button3();
if (button3_pressed) {
button_pressed +=4;
}
Serial.print(button_pressed);


switch(button_pressed) {
some code...

Do I have to do something special to use D11?

Thanks
Mike

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Flora can't read D11 button press

Post by adafruit_support_rick »

Are you sure you have a secure connection to D11? You might try touching up the solder. Have you tried a different pin instead of D11?

BTW, Arduino added an INPUT_PULLUP configuration. You can replace this:

Code: Select all

pinMode(BUTTON1_PIN, INPUT);
digitalWrite(BUTTON1_PIN,HIGH); // pull-up
with this:

Code: Select all

pinMode(BUTTON1_PIN, INPUT_PULLUP); // enable pull-up

User avatar
wingnut59
 
Posts: 15
Joined: Tue Mar 05, 2013 11:55 pm

Re: Flora can't read D11 button press

Post by wingnut59 »

Thanks for the pull-up info, I'll take a look at my solder joints again but they look good. maybe my switch is malfunctioning.
Mike

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

Return to “Other Arduino products from Adafruit”