Memorial day is 05/25/2015 – Orders will ship out on May 26th. There will not be any deliveries or shipping on Monday. Any order placed after 11am ET on Friday May 22nd will not start to ship out until Tuesday May 26th.

Flora can't read D11 button press
Moderators: adafruit_support_bill, adafruit

Flora can't read D11 button press

by wingnut59 on Wed Mar 06, 2013 12:05 am

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
wingnut59
 
Posts: 4
Joined: Tue Mar 05, 2013 11:55 pm

Re: Flora can't read D11 button press

by adafruit_support_rick on Wed Mar 06, 2013 8:50 am

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 | TOGGLE FULL SIZE
pinMode(BUTTON1_PIN, INPUT);
digitalWrite(BUTTON1_PIN,HIGH); // pull-up

with this:
Code: Select all | TOGGLE FULL SIZE
pinMode(BUTTON1_PIN, INPUT_PULLUP); // enable pull-up

adafruit_support_rick
 
Posts: 18426
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Flora can't read D11 button press

by wingnut59 on Wed Mar 06, 2013 9:02 pm

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
wingnut59
 
Posts: 4
Joined: Tue Mar 05, 2013 11:55 pm