@Paul S..I have the encoder talking to the arduino.. It is a 2500 (yes 2500ppm) model so I need to scale it down as the arduino only wants to see 1024 counts.. As for the keypad, I havent attempted it yet as I am stuck on scaling the encoder input..
Here is my code so far>> I didn't write the original, I have edited to try to accomplish my task. I added PIN 15 to try to use a push button to reset the encoder count to 0. I didn't know where to go after defining the pin..My train of thought is this. If I can get the encoder scaled to be accepted by the arduino and I can print to the LCD, then I will work on the reset button.I can only get a count to 1023 on my LCD..
#include <LiquidCrystal.h>
#define encoder0PinA 3
#define encoder0PinB 2
#define analogOutPin 5
#define analogInPin 15
LiquidCrystal lcd(12,11,7,6,5,4);
volatile unsigned int encoder0Pos = 0;
unsigned int tmp = 0;
unsigned int Aold = 0;
unsigned int Bnew = 0;
void setup() {
pinMode(encoder0PinA, INPUT);
pinMode(encoder0PinB, INPUT);
// encoder A on interrupt 1 (pin 3)
attachInterrupt(1, doEncoderA, CHANGE);
// encoder B on interrupt 0 (pin 2)
attachInterrupt(0, doEncoderB, CHANGE);
}
void loop(){
//if position has changed, display it on LCD
if (tmp != encoder0Pos) {
tmp = encoder0Pos;
//for (int loopCnt = 0; loopCnt < (tmp / 2500) +1 ; loopCnt++1);
}
lcd.begin(16,1);
lcd.setCursor(5,0);
lcd.print(tmp);
delay(170);
}
// Interrupt on A changing state
void doEncoderA(){
// if Bnew = Aold, increment, otherwise decrement
Bnew^Aold ? encoder0Pos++:encoder0Pos--;
Aold=digitalRead(encoder0PinA);
// check for underflow (< 0)
if (bitRead(encoder0Pos, 150) == 1) encoder0Pos = 0;
// check for overflow (> 1023)
if (bitRead(encoder0Pos, 100) == 1) encoder0Pos = 1023;
constrain(encoder0Pos, 0, 1023);
}
// Interrupt on B changing state
void doEncoderB(){
Bnew=digitalRead(encoder0PinB);
// if Bnew = Aold, increment, otherwise decrement
Bnew^Aold ? encoder0Pos++:encoder0Pos--;
// check for underflow (< 0)
if (bitRead(encoder0Pos, 15) == 1) encoder0Pos = 0;
// check for overflow (> 1023)
if (bitRead(encoder0Pos, 10) == 1) encoder0Pos = 1023;
}