mirror of
https://github.com/JeffersGlass/DDS_VFO.git
synced 2024-11-27 10:47:36 -06:00
810a91b366
Uploaded Si5351 library and encoder library
47 lines
1.2 KiB
Plaintext
47 lines
1.2 KiB
Plaintext
/* Encoder Library - TwoKnobs Example
|
|
* http://www.pjrc.com/teensy/td_libs_Encoder.html
|
|
*
|
|
* This example code is in the public domain.
|
|
*/
|
|
|
|
#include <Encoder.h>
|
|
|
|
// Change these pin numbers to the pins connected to your encoder.
|
|
// Best Performance: both pins have interrupt capability
|
|
// Good Performance: only the first pin has interrupt capability
|
|
// Low Performance: neither pin has interrupt capability
|
|
Encoder knobLeft(5, 6);
|
|
Encoder knobRight(7, 8);
|
|
// avoid using pins with LEDs attached
|
|
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
Serial.println("TwoKnobs Encoder Test:");
|
|
}
|
|
|
|
long positionLeft = -999;
|
|
long positionRight = -999;
|
|
|
|
void loop() {
|
|
long newLeft, newRight;
|
|
newLeft = knobLeft.read();
|
|
newRight = knobRight.read();
|
|
if (newLeft != positionLeft || newRight != positionRight) {
|
|
Serial.print("Left = ");
|
|
Serial.print(newLeft);
|
|
Serial.print(", Right = ");
|
|
Serial.print(newRight);
|
|
Serial.println();
|
|
positionLeft = newLeft;
|
|
positionRight = newRight;
|
|
}
|
|
// if a character is sent from the serial monitor,
|
|
// reset both back to zero.
|
|
if (Serial.available()) {
|
|
Serial.read();
|
|
Serial.println("Reset both knobs to zero");
|
|
knobLeft.write(0);
|
|
knobRight.write(0);
|
|
}
|
|
}
|