Turbo46
 Guru
 Joined: 24/12/2017 Location: AustraliaPosts: 1693 |
| Posted: 07:16pm 01 Dec 2020 |
|
|
|
In Geoff's Programming with the Colour Maximite 2 Document there is a chapter on Using a Switch as an Input on page 62.
I would use an external pullup resistor because I have found that when using the internal pullup resistor, sometimes noise can trigger false inputs if the wire to the switch is too long. 100mS delay to allow for switch bounce has worked well for me.
I would use an interrupt on low for the switch input pin so that, depending on what your program is doing, it wont miss a short button push.
The interrupt subroutine would: disable interrupts to stop contact bounce re-triggering it. set a flag to show the switch has operated and return
In the main program loop (having cleared the flag and set up the pin first) . . check the flag if it is set then pause 100mS (to de-bounce the switch) increment the variable clear the flag re-enable the interrupt on low endif . . loop
That could be best done in a subroutine.
I hope you're on the mend. I know from experience that paper work can be difficult left-handed. Bill |