hello!
Contextualization: Im using my arduino uno to drive my DS1307 based clock, which will show HH:MM:DD, DD/MM and temperature (twelve 7 segment displays).
what i am doing now: i want to use both interrupts to act as increase/decrease functions to set time, alarm, date, etc. im using two simple push buttons.
problem: since im multiplexing, i want to avoid as much as possible coding to increase multiplexing speed. i want to debounce the buttons via hardware.
i have tried:
simple pullup resistor -> no success.
simple pulldown resistor -> no sucess.
pullup and pulldown with capacitor side by side with button (1nF, 10nF, 100nF, 1uF, 10uF) -> no sucess
added a 7414 schmidt trigger -> half sucess.
see the video. when i press the button, the interrupt adds a number correctly to the counter, but when i release it, it stills add to the counter (which shows on the display).
Even with the simple software debouncing i have made, this seems to continue; sometimes the interrupt triggers insanely and the counter goes to like 70 or 80 in 1 button click (as in video).
*ignore thousands of transistors. i will change the 7-segments for bright LEDs after everything is okay.
any idea whay should i do to avoid this with minimum coding?
thanks!
codes im using.
int latchPin = 12;
int clockPin = 13;
int dataPin = 11;
int counter = 0;
int last_push = 0; //usado no debounce
int debounce_time = 100; //milisegundos para o debounce
--- multiplexing stuff ---
void setup() {
attachInterrupt(0, counter_soma, RISING);
attachInterrupt(1, counter_subtrai, RISING);
--- multiplexing stuff ---
}
void loop() {
//this simply prints the number on the counter on a certain display on the board. no big deal. (with shift registers)
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, segmento[counter]);
shiftOut(dataPin, clockPin, MSBFIRST, numero[counter]);
digitalWrite(latchPin, HIGH);
}
that's the main block (still a lot of work to do)
now th einterrupts
void counter_soma(){
if ((millis() - last_push) > debounce_time){
last_push = millis();
counter ++;
Serial.println(counter);
}
}
void counter_subtrai(){
if ((millis() - last_push) > debounce_time){
last_push = millis();
counter --;
Serial.println(counter);
};
}
and now a simple pic of the buttons.