No Raduino here, but do have a Nano to play with. ?Here's a code scrap to replace that final clause in doTuning() to give the tuning pot a bit of hysterisis. ?Perhaps somebody could try it out.
// the tuning knob is at neither extremities, tune the signals as usual
else if (knob != old_knob){
static char dir_knob;
if ( (knob>old_knob) && ((dir_knob==1) || ((knob-old_knob) >5)) ||
(knob<old_knob) && ((dir_knob==0) || ((old_knob-knob) >5)) ) {
if (knob>old_knob) {
dir_knob=1;
frequency = baseTune + (50l * (knob-5));
} else {
dir_knob=0;
frequency = baseTune + (50l * knob);
}
old_knob = knob;
setFrequency(frequency);
updateDisplay();
}
o
tone(CW_TONE, sideTone);
tone(6, 1000);
Also, if you want a 1000hz square wave on pin 6 as a test signal, just execute this line somewhere:
? ? tone(6,1000);
That sets up a counter-timer to continuously generate the square wave while the Nano goes off and does other things.
Shut it down with
? ? noTone();
Jerry, KE7ER