I am using the Phi_interface library and this code:
#include <phi_interfaces.h>
#define Encoder1ChnA 2
#define Encoder1ChnB 3
#define EncoderDetent 12
char mapping1[]={'U','D'}; // This is a rotary encoder so it returns U for up and D for down on the dial.
phi_rotary_encoders my_encoder1(mapping1, Encoder1ChnA, Encoder1ChnB, EncoderDetent);
multiple_button_input* dial1=&my_encoder1;
void setup()
{
Serial.begin(9600);
}
void loop()
{
char temp;
//Rotary encoder 1:
// temp=my_encoder1.getKey(); // Use phi_keypads object to access the keypad
temp=dial1->getKey(); // Use the phi_interfaces to access the same keypad
if (temp!=NO_KEY) Serial.println(temp);
}
I have 2 problems...
-
How do I change the pin numbers of channel A and B (changing the numbers in the define command does not seem to work).
-
How do I actually use the "U" and "D" to control a variable... for instance: If (temp == U); seconds++; and If (temp == D); seconds--;
So basically if the shaft encoder turns clockwise then the seconds increase and vice versa for anti clockwise.
Could you give me an example code please