larryd:
Potentiometer to 1/2 scale # stays unchanged.
Potentiometer to full scale # increases.
Potentiometer to zero scale #decreases.
Happy New Year
//**********************************************************************
//
// Version YY/MM/DD Comments
// 1.01 18/12/01 Running code
//
// Adjust two potentiometers to clculate a sum value.
//
//**********************************************************************
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
// LCD pins: RS EN DB4 DB5 DB6 DB7
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
//i/o
const byte firstNumberPot = A0;
const byte secondNumberPot = A1;
//sram
int firstNumberPotReading;
int firstValue;
int secondNumberPotReading;
int secondValue;
//timing stuff
unsigned long firstValueMillis;
unsigned long secondValueMillis;
unsigned long printMillis;
//**********************************************************************
void setup()
{
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// 0123456789111111
// 012345
lcd.print("Pot. Calculator");
delay(2000);
} //END of setup()
//**********************************************************************
void loop()
{
//*********************************************
//adjust the first variable
firstNumberPotReading = analogRead(firstNumberPot);
//don't adjust
if (firstNumberPotReading > 450 && firstNumberPotReading < 550)
{
//do nothing
}
//slow increment
else if (firstNumberPotReading > 550 && firstNumberPotReading < 700)
{
if (millis() - firstValueMillis >= 500)
{
//restart timer
firstValueMillis = millis();
firstValue++;
}
}
//slow decrement
else if (firstNumberPotReading < 400 && firstNumberPotReading > 300)
{
if (millis() - firstValueMillis >= 500)
{
//restart timer
firstValueMillis = millis();
firstValue--;
}
}
//fast increment
else if (firstNumberPotReading > 700)
{
if (millis() - firstValueMillis >= 100)
{
//restart timer
firstValueMillis = millis();
firstValue++;
}
}
//fast decrement
else if (firstNumberPotReading < 300)
{
if (millis() - firstValueMillis >= 100)
{
//restart timer
firstValueMillis = millis();
firstValue--;
}
}
//*********************************************
//adjust the second variable
secondNumberPotReading = analogRead(secondNumberPot);
//don't adjust
if (secondNumberPotReading > 450 && secondNumberPotReading < 550)
{
//do nothing
}
//slow increment
else if (secondNumberPotReading > 550 && secondNumberPotReading < 700)
{
if (millis() - secondValueMillis >= 500)
{
//restart timer
secondValueMillis = millis();
secondValue++;
}
}
//slow decrement
else if (secondNumberPotReading < 400 && secondNumberPotReading > 300)
{
if (millis() - secondValueMillis >= 500)
{
//restart timer
secondValueMillis = millis();
secondValue--;
}
}
//fast increment
else if (secondNumberPotReading > 700)
{
if (millis() - secondValueMillis >= 100)
{
//restart timer
secondValueMillis = millis();
secondValue++;
}
}
//fast decrement
else if (secondNumberPotReading < 300)
{
if (millis() - secondValueMillis >= 100)
{
//restart timer
secondValueMillis = millis();
secondValue--;
}
}
//*********************************************
if (millis() - printMillis >= 500)
{
//restart timer
printMillis = millis();
Serial.print(firstValue);
Serial.print(" + ");
Serial.print(secondValue);
Serial.print(" = ");
Serial.println(firstValue + secondValue);
lcd.setCursor(0, 0);
//clear the line
// 111111
// 0123456789012345
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print(firstValue);
lcd.print(" + ");
lcd.print(secondValue);
lcd.print(" = ");
lcd.print(firstValue + secondValue);
}
} //END of loop()
//**********************************************************************
Thank you larryd!
I ended up with this and it does work! Thanks for the help! I will add other parts of your suggested code as I build my monster.
/*
*
- Pot Addition Calculator for small numbers. A starting point for more complicated things

- Modified from example code in Arduino IDE
Analog input, analog output, serial output
Reads an analog input pin, maps the result to a range from 0 to 255 and uses
the result to set the pulse width modulation (PWM) of an output pin.
Also prints the results to the Serial Monitor and LCD
The circuit:
- 2 potentiometers connected to analog pins 0 and 1.
Center pin of the potentiometers go to the analog pins.
side pins of the potentiometers go to +5V and ground
- LED connected from digital pin 9 to ground (commented out)
- 16 by 2 LCD
created 29 Dec. 2008
modified 9 Apr 2012
by Tom Igoe
Modified again by Peter Liwyj Dec 30 2019
Also includes code by larryd from the Arduino forums
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/AnalogInOutSerial
*/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
// LCD pins: RS EN DB4 DB5 DB6 DB7
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
// These constants won't change. They're used to give names to the pins used:
const int analogInPin1 = A1; // Analog input pin that the potentiometer is attached to
const int analogInPin2 = A2; // Analog input pin that the second potentiometer is attached to
//const int analogOutPin1 = 9; // Analog output pin that the LED is attached to
//const int analogOutPin2 = 8; // Analog output pin that the LED is attached to
int sensorValue1 = 0; // value read from pot1
int outputValue1 = 0; // value output to the PWM (analog out)
int sensorValue2 = 0; // value read from pot2
int outputValue2 = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
lcd.print("Pot. Calculator"); // Send "Pot. calculator" to LCD
delay(2000); // Screen delay
}
void loop() {
// read the analog in value of pot1:
sensorValue1 = analogRead(analogInPin1);
// read the analog in value of pot2:
sensorValue2 = analogRead(analogInPin2);
// map pot1 to the range of the analog out:
outputValue1 = map(sensorValue1, 0, 1023, 1, 20);
// map pot2 to the range of the analog out:
outputValue2 = map(sensorValue2, 0, 1023, 1, 20);
// change the analog out value of pot1:
// analogWrite(analogOutPin1, outputValue1);
// change the analog out value of pot2:
// analogWrite(analogOutPin2, outputValue2);
// print the results to the Serial Monitor for pot 1:
Serial.print("sensor 1 = ");
Serial.print(sensorValue1);
Serial.print("\t output 1 = ");
Serial.println(outputValue1);
// print the results to the Serial Monitor for pot 2:
Serial.print("sensor 2 = ");
Serial.print(sensorValue2);
Serial.print("\t output 2 = ");
Serial.println(outputValue2);
lcd.setCursor(0, 0); //clear the line
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print(sensorValue1);
lcd.print(" + ");
lcd.print(sensorValue2);
lcd.print(" = ");
lcd.print(sensorValue1 + sensorValue2);
delay(1000);
}