Hmm .. Seems like the board has suggested like questions, but they appear locked.
So I've popped up a few times here, and you've all been helpful.
I'm not actually "doing" anything .. just learning the code, starting with the basics and trying to expand and implement instructions to "do" something simple with a test circuit.
I did get my 2x20 line VFD clock working after figuring out the serial comm had to be inverted with a transistor.
I know it's one-oh-one, and drifty with the delay statement as master time, but I like what I've written. Probably no use to any of you who aren't using the same Futaba display, but here it is anyway - the simplest clock I could write.
int s = 45; int m = 59; int h = 12; int x = 1; // time will start at 12:59:54 PM. X is AM/PM flag. .
void setup() {
pinMode(3, INPUT); pinMode(4, INPUT); // buttons on pin 3 and 4, normally high through 10K pull up.'
Serial.begin(9600, SERIAL_8N1); // config serial TX pin 1.
}
void loop() {
Serial.write(0x12);Serial.write(" Time "); // clear display and center time.
if(h<10)Serial.write("0"); // correct 2 digits.
Serial.print(h); Serial.write(":"); // print hours then colon.
if(m<10)Serial.write("0"); // correct 2 digits.
Serial.print(m); Serial.write(":"); // print minutes then colon.
if(s<10)Serial.write("0"); // correct 2 digits.
Serial.print(s); // print seconds.
if(x==0) Serial.write(" AM");if(x==1) Serial.write(" PM"); // solve AM/PM displayed.
Serial.write(" HAVE A GREAT DAY"); // print whatever, second line.
(s++); // increment count time.
if(s==60){s=0; m=m+1;} // solve count, overflow, and handling.
if(m==60){m=0; h=h+1;}
if(h==13){ h=1; x=x+1; if(x==2)x=0;} // AM/PM overflow.
if (digitalRead(3) == LOW && digitalRead(4) == HIGH) {(h++);} // buttons to set time.
if (digitalRead(4) == LOW && digitalRead(3) == HIGH) {(m++);}
if (digitalRead(4) == LOW && digitalRead(3) == LOW) {both();} // do something else if both pushed.
delay (968); // master second delay.
}
void both(){Serial.write(0x12);Serial.write("Error"); // here if both buttons pushed.
}
Next month I'll be better still.
So the actual question ..
Note that electronics are not my weak hand, just learning the Arduino parlez by connecting to random things.
Today's bench play is interfacing an X/Y keypad .. I can figure that one out .. and an old rotary phone dial which has two pair of contacts. The pair of interest makes and breaks at 20 pulses per second proportional to the number dialed . ie, seven is seven pulses at 20Hz.
I'm drawing a blank how to actually count pulses though.
I'm pretty certain I could just use if/digitalRead and increment with something as "slow" as 20Hz .. but it seems somehow messy.
Not asking for anyone to do my homework that I can CTRL+C, just a nudge or thought as to where in the sandbox I need to dig.
As always, thanks.
Jimbo.