Yesterday I had a little time to go on with my high speed photo controller project. I added three more buttons. The circuits are exactly the same as for the first button. Here is a picture:
As you can see, I put every button connector two a new column. This way it was easy to wire them and I needed to make cuts only between the connector pins. I also changed the code of the controller:
// include the library code:
#include <LiquidCrystal.h>
const int numRows = 2;
const int numCols = 16;
const int lcdBackLightPin = 12;
const int upButtonPin = 6;
const int downButtonPin = 5;
const int setButtonPin = 4;
const int resetButtonPin = 3;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 11, 10, 9, 8, 7);
void setup() {
// set up the LCD's number of rows and columns:
lcd.begin(numRows, numCols);
lcd.clear();
lcd.setCursor(5, 1);
lcd.print("XistiX");
digitalWrite(lcdBackLightPin, HIGH);
pinMode(lcdBackLightPin, OUTPUT);
pinMode(upButtonPin, INPUT);
pinMode(downButtonPin, INPUT);
pinMode(setButtonPin, INPUT);
pinMode(resetButtonPin, INPUT);
}
void loop() {
if(digitalRead(upButtonPin))
{
lcd.setCursor(0, 0);
lcd.print("UP Button");
}
else if(digitalRead(downButtonPin))
{
lcd.setCursor(0, 0);
lcd.print("DOWN Button");
}
else if(digitalRead(setButtonPin))
{
lcd.setCursor(0, 0);
lcd.print("SET Button");
}
else if(digitalRead(resetButtonPin)
)
{
lcd.setCursor(0, 0);
lcd.print("RESET Button");
}
else
{
lcd.setCursor(0, 0);
lcd.print(" ");
}
}
It prints to the screen which button is pressed. When you check the source you will notice that buttons actually has a priority order and you can’t press two more than one button at the same time. I used an if else if structure. I will change this later. It is simply so because it was the easiest to test the buttons and update the screen.
You can download the code as a file from here: xISTIx_Buttons

0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
You must be logged in to post a comment.