Add an external pull down resistor, so the default state is LOW.To recap, you have 3 choices, depending on the default state you want for the button: In this tutorial you’ve seen how to properly use pull up and pull down resistors for your Arduino sensors, and when to use the INPUT_PULLUP option for the pinMode function. And in this example when I pressed the button the state rose to HIGH. Great! Now the default value when the button is not pressed is LOW. When you run the program using pinMode(BUTTON_PIN, INPUT), you’ll get:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |