I have added two potentiometers to the board. Actually I had only one potentiometer but the board is ready for the other one as well. It was fairly easy. I just added two connectors each with two pins. The first connector is sitting on the +5v and GND lines. The other one is connected to the analog input 0 and 1 pins. Since in both case the pins are neighboring pins on the arduino I didn’t need to make additional connections. Just solder the pins and that is it. When I was ready I crimped two cables for the connectors. I soldered the two wires of the first cable to the two side pins of the potentiometer. I connected this cable to the connector on the +5V-GND. Then I soldered one wire from the second cable two the middle pin of the potentiometer.
When I will get the second potentiometer I will connect its side pins to the corresponding pins on the other potentiometer. The middle pin will be connected to the free wire on the second cable.
I will use the connected potentiometer for setting a treshold value. For instance it can be used for calibrating microphone input. The second potentiometer will be used to input delay values. I will use a precision potentiometer (turns 10x) for that.
Here is a picture of the hardware:
I also added the treshold input to the code:
// include the library code:
#include <LiquidCrystal.h>
const int numRows = 2;
const int numCols = 16;
//Digital pins
const int lcdBackLightPin = 12;
const int upButtonPin = 6;
const int downButtonPin = 5;
const int setButtonPin = 4;
const int resetButtonPin = 3;
//Analog pins
const int tresholdPin = 0;
char* mainMenu[]={"start", "delay", "treshold", "test"};
int mainMenuIndex = 0;
int mainMenuNextItem = 1;
int mainMenuItemNum = 4;
boolean menuUpdate = false;
int treshold = 0;
// 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(0, 0);
lcd.print(">");
lcd.setCursor(2, 0);
lcd.print(mainMenu[mainMenuIndex]);
lcd.setCursor(2, 1);
lcd.print(mainMenu[mainMenuNextItem]);
digitalWrite(lcdBackLightPin, HIGH);
pinMode(lcdBackLightPin, OUTPUT);
pinMode(upButtonPin, INPUT);
pinMode(downButtonPin, INPUT);
pinMode(setButtonPin, INPUT);
pinMode(resetButtonPin, INPUT);
}
void setTreshold()
{
int cursorOn = 1;
delay(300);
while(!digitalRead(setButtonPin))
{
treshold = analogRead(tresholdPin);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Treshold:");
lcd.setCursor(0, 1);
if(cursorOn)
{
lcd.print("> ");
cursorOn = 0;
}
else
{
lcd.print(" ");
cursorOn = 1;
}
lcd.print(treshold);
delay(300);
}
}
void loop() {
if(digitalRead(upButtonPin))
{
mainMenuIndex++;
if(mainMenuIndex >= mainMenuItemNum)
{
mainMenuIndex = 0;
}
mainMenuNextItem++;
if(mainMenuNextItem >= mainMenuItemNum)
{
mainMenuNextItem = 0;
}
menuUpdate = true;
}
else if(digitalRead(downButtonPin))
{
mainMenuIndex--;
if(mainMenuIndex < 0)
{
mainMenuIndex = mainMenuItemNum - 1;
}
mainMenuNextItem--;
if(mainMenuNextItem < 0)
{
mainMenuNextItem = mainMenuItemNum - 1;
}
menuUpdate = true;
}
else if(digitalRead(setButtonPin))
{
switch(mainMenuIndex)
{
/*
case 0:
break;
case 1:
break;
*/
case 2: setTreshold();
menuUpdate = true;
break;
/*
case 3:
break;
default:
*/
}
}
if(menuUpdate)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(">");
lcd.setCursor(2, 0);
lcd.print(mainMenu[mainMenuIndex]);
lcd.print(" <");
lcd.setCursor(2, 1);
lcd.print(mainMenu[mainMenuNextItem]);
menuUpdate = false;
delay(300);
}
}

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.