There are lots of different types of switches from momentary switches (aka buttons) to toggle or slide switches (which maintain their state) to switches that activate based on environmental conditions like a tilt switch or a reed switch. SwitchesĪs noted above, switches are simple components: they’re typically either “open” (disconnected) or “closed” (connected). We’ll learn more about this circuit in this lesson. When the button is pressed, current flows from \(V_\) through the pull-down resistor to GND. In fact, (virtually) no current flows into Pin 2! Why not? We’ll talk about this and more in this lesson!Īnimation shows the Arduino’s built-in LED illuminating when the button on Pin 2 is pressed. Importantly, notice where the current flows when the button is pressed-perhaps surprisingly, it does not flow into Pin 2. Try to understand the why and how of these resistors in your circuits.įor example, in the animation below, we show a button circuit with a pull-down resistor hooked up to Pin 2. However, when using switches with microcontrollers, we’ve found that students often struggle to understand why pull-up or pull-down resistors are necessary. We use switches everyday when we turn on and off our light circuits in our home. Switches themselves are conceptually easy to understand-they are either “closed” or “open”. We’ll cover buttons (aka momentary switches), how to use digital input with the digitalRead function, and pull-up and pull-down resistors. In this lesson, we’ll finally get to build something interactive: turning on an LED with a push button. We assume you’ve already completed the Intro to Arduino Output series. This is the first lesson in the Intro to Arduino Input lesson series.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |