Hello to all... I have made a custom Keypad with 12 buttons. I am using AnalogButtons.h library by Neil DUdman.
http://www.arduino.cc/playground/Code/AnalogButtons
As per the procedure given by Neil i enabled the
//AnalogButtons::configure(ANALOG_PIN); //delay(1000);
line of code and found the Minimum and Maximum values of all 12 buttons and modified the sketch accordingly for all 12 buttons.
Then i commented the above line , Compile the sketch uploaded into Arduino and checked in the serial monitor for the the button pressed. Buttons from 1 to 10 when pressed giving me indication on the Serial monitor but button 11 and 12 gives no indication.
Following is the complete sketch. Please help.
#include "AnalogButtons.h"
#define ANALOG_PIN 0
// A call back function that you pass into the constructor of AnalogButtons, see example
// below. Alternitivly you could extend the Button class and re-define the methods pressed()
// or held() which are called
void handleButtons(int id, boolean held)
{
if (held) {
Serial.print("button id="); Serial.print(id); Serial.println(" was pressed and held");
} else{
Serial.print("button id="); Serial.print(id); Serial.println(" was pressed only");
}
}
AnalogButtons analogButtons(ANALOG_PIN, 30, &handleButtons);
Button b1 = Button(1, 47,50);
Button b2 = Button(2, 84, 87);
Button b3 = Button(3, 127, 130);
Button b4 = Button(4, 194, 198);
Button b5 = Button(5, 303,309);
Button b6 = Button(6, 405, 410);
Button b7 = Button(7, 546, 549);
Button b8 = Button(8, 690, 695);
Button b9 = Button(9, 780,785);
Button b10 = Button(10, 864, 870);
Button b11 = Button(11, 925, 935);
Button b12= Button(12, 955, 965);
// Default hold duration is 1 second, lets make it 5 seconds for button5
//Button b5 = Button(5, 860, 875, 5);
void setup()
{
Serial.begin(9600);
Serial.println("Testing your Analog buttons");
analogButtons.addButton(b1);
analogButtons.addButton(b2);
analogButtons.addButton(b3);
analogButtons.addButton(b4);
analogButtons.addButton(b5);
analogButtons.addButton(b6);
analogButtons.addButton(b7);
analogButtons.addButton(b8);
analogButtons.addButton(b9);
analogButtons.addButton(b10);
analogButtons.addButton(b11);
analogButtons.addButton(b12);
}
void loop()
{
// To check values when button are pressed
analogButtons.checkButtons();
// To configure the MAX/Min values for each
// Button, uncomment this line, make sure you've called Serial.begin(9600);
// Then in turn hold town each botton, noting the max/min values
//AnalogButtons::configure(ANALOG_PIN); //delay(1000);
}