The Arduino can respond to multiple things if the loop() runs very fast over and over again. In your case, that might not be needed, so you can go ahead and maybe later worry about debouncing. That is why every serious sketch debounces the buttons. I'm using it as a memory to know if the arm should increment or decrement after a stop. Int prevpos = 0 //To store the previous position of servo. Int pushval = 0 //Stores push button state I am not able to get the loop to stop if the state of the button changes. If the degree is less than 90 degrees then the degree should increment as long as the button is pushed and after reaching 90 it should decrement if the button is pressed. I am trying to control a servo using only one push button.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |