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
Flora can't read D11 button press
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Flora can't read D11 button press
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:
with this:
BTW, Arduino added an INPUT_PULLUP configuration. You can replace this:
Code: Select all
pinMode(BUTTON1_PIN, INPUT);
digitalWrite(BUTTON1_PIN,HIGH); // pull-up
Code: Select all
pinMode(BUTTON1_PIN, INPUT_PULLUP); // enable pull-up
- wingnut59
- Posts: 15
- Joined: Tue Mar 05, 2013 11:55 pm
Re: Flora can't read D11 button press
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
Mike
Please be positive and constructive with your questions and comments.