Skip to content

Instantly share code, notes, and snippets.

@EarToEarOak
Last active September 20, 2018 12:42
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save EarToEarOak/6fb321b604602373f93a to your computer and use it in GitHub Desktop.
Control the frequency in SDR# with a rotary encoder. From the tutorial http://eartoearoak.com/tutorials-and-examples/sdrsharp-physical-controls
/*
Basic example demonstrating the how to control SDR# frequency
with SDRSharp Net Remote, an Arduino and rotary encoder.
Copyright 2015 Al Brown
Requires:
http://eartoearoak.com/software/sdrsharp-net-remote
http://www.pjrc.com/teensy/td_libs_Encoder.html
Connections:
Encoder Arduino
A D3
B D2
C GND
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Encoder.h>
// Initialise the encoder on digital pins 2 & 3
Encoder encoder(2, 3);
long oldPos = -999;
// Initial frequency
long frequency = 100000000;
void setup() {
Serial.begin(115200);
}
void loop() {
// Get the encoder position
long newPos = encoder.read();
if (newPos != oldPos) {
oldPos = newPos;
// Send the command to change the frequency via the serial port
Serial.print("{\"Command\": \"Set\", \"Method\": \"Frequency\", \"Value\": ");
Serial.print(frequency + (newPos * 1000));
Serial.println("}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment