Lovetronic WROTE:Someone can advice me what switch is suitable to use in my remote control. I had tried push button however it does not compatible with the coding (I'm using chipkit UNO32). My intention is to make the user select AUTO mode or MANUAL Mode. After selecting, the user will ask to select speed and duration. So this requires a lot of loop-inside-a-loop, if-inside-if etc. When I'm using push button, the microcontroller cannot read the command when the second button is push.
Hi,
This is not the hardware problem, is your program flow. If i not understand wrong, what you want is something like can select a menus, after select the menu, inside have speed and duration. to make you programming easy, you need to write a code that detect push button with interrupt, normally PIC32 PORTB has On-change interrupt, so every time user press button, it will goes to On-change interrupt. in interrupt, you can activate a timer(PIC32 a lot of timer ) to de-bounce the push button.
Once confirm button is push by read the input, increase your menu position counter. if 1 mean go to menu 1, if 2 go to menu 2. Once counter more then two, roll it back to 0, why ? because you only have 2 menus. After you know the menu position, you need another counter for sub-menu, just follow the same way.
If you are using polling method to read push button, it is very hard to make sure it will not miss the pressing count.
hope this help.