60Views4Replies

Author Options:

REMOTE CONTROL Answered

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 be asked 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. I heard, if using push button I need electronic relay. 

Discussions

0
None
nomuse

5 years ago

Also, if I am understanding the description of your code, no-exit loops are evil. Better to loop through the main program constantly, and if the status change you are looking for occurs, set a flag. Then you can have a flag test inside the if/then conditionals next time they loop past.

0
None
caitlinsdad

5 years ago

First step: look up any tutorial on using a switch on an arduino. Depending on if the pushbutton is normally open circuit or closed circuit without pressing the button, the arduino will see it as either HIGH or LOW and then reverse those reading when the switch is pressed. You have to code the program to do what is based on the expected readings. You may need to wire up the switch with a pullup resistor. You may need to add in some "debounce" code to make sure the switch is pressed one time. You should make sure you have one switch working by making it light up the onboard LED. Then you can expand your program to do the rest. Good luck.

0
None
caitlinsdadlovetronic

Reply 5 years ago

Because the arduino is looping through your program so fast, it may seem to the program that the switch is constantly being pressed. You can set up a variable to keep track of what state the switch is in and compare it again after a delay to may sure it was just pressed once and you let go. Arduino.cc is the reference site for arduinos to check the sample code and tutorials.