This way you just need to modify one line of the code, which is at the top of the program – and thus easy to find. This will make your life easier, especially if you want to plug the button to another pin later on. Code to setup the push button #define BUTTON_PIN 4įirst we create a #define for the button pin, so we don’t need to write “4” every time we want to use this pin in our code. Here is the code to print the button’s state 10 times a second. > Watch this video as an additional resource to this tutorial section:Īfter watching the video, subscribe to the Robotics Back-End Youtube channel so you don’t miss the next tutorials! Print the push button’s state What we’re trying to do here is to simply read the state from the button and print it 10 times per second. Also, if you want to know more about Arduino pins, check out this Arduino Uno pinout guide. In the following of this post we’ll talk more about this. This other wire goes to a digital pin, for example 4.Īs for now there is no resistor involved in the circuit. If you have plugged the GND wire on the left side, then plug another wire on the right side, so they are not connected together.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |