PIC P16F690;
pragma debounce count = 5;
pragma debounce delay = 1ms;
Main {
digital_output PORTC;
digital_input RA3;
$display = 0;
Loop {
debounce RA3,
Action {
++$display;
write PORTC, $display;
};
}
}
Simulator {
attach_led PORTC, 4, 'red';
logfile "debouncer.lxt";
log RA3;
scope RA3;
# stimulus should reflect the debounce delay to be viable
stimulate RA3, every 5s, wave [
300, 1, 1300, 0,
1400, 1, 2400, 0,
2500, 1, 3500, 0,
3600, 1, 4600, 0,
4700, 1, 5700, 0,
5800, 1, 6800, 0,
6900, 1, 8000, 0
];
stop_after 30s;
autorun;
}