
Push Buttons — SIK Circuit 5
ညွှန်ကြားချက်များ
Parts & Introduction
Parts & Introduction
Push buttons are the simplest digital input. This experiment uses two buttons with an XOR logic gate: the LED turns on if you press either button, but turns off if you press both. You'll learn about digitalRead(), pull-up resistors, and boolean logic.
Parts Needed
- 1x Arduino Uno + USB cable
- 1x Breadboard
- 2x Push Buttons
- 1x LED (any color)
- 1x 330Ω Resistor
- 2x 10KΩ Resistors (pull-ups)
- 7x Jumper Wires
ဤအဆင့်အတွက် ကုန်ကြမ်းများ:
SparkFun Inventor's Kit - V3.21 အစုံလိုအပ်သော ကိရိယာများ:
Computer with Arduino IDEHardware Hookup
Hardware Hookup
Wiring Instructions
- Place both push buttons across the center canyon of the breadboard.
- Button 1: Connect one pin to GND. Connect the opposite diagonal pin to Arduino Digital Pin 2. Add a 10K resistor between Pin 2 and 5V (pull-up).
- Button 2: Connect one pin to GND. Connect the opposite diagonal pin to Arduino Digital Pin 3. Add a 10K resistor between Pin 3 and 5V (pull-up).
- Connect LED positive leg to Digital Pin 13, negative leg through 330Ω resistor to GND.
Note: The pull-up resistors hold the input HIGH when the button is not pressed. Pressing the button connects the pin to GND (LOW).
ဤအဆင့်အတွက် ကုန်ကြမ်းများ:
Push Button2 ခု
Breadboard1 ခု
Jumper Wires7 ခုArduino Code
Arduino Code
Open the Arduino IDE and upload the following sketch to your Arduino board.
ဤအဆင့်အတွက် ကုန်ကြမ်းများ:
Arduino Uno R31 ခုလိုအပ်သော ကိရိယာများ:
Computer with Arduino IDETest & Experiment
Test & Experiment
What You Should See
The LED turns on when you press either button individually. It turns off when you press both buttons simultaneously (XOR logic).
Troubleshooting
- Not responding: Push buttons are square — it's easy to put them in the wrong orientation. Try rotating 90°.
- LED always on or always off: Check the pull-up resistor connections. Without them, the input pin floats and reads random values.
Experiments to Try
- Change the logic to AND (both buttons required) or simple OR.
- Use the buttons to control an RGB LED — one button for color, one for brightness.
- Try using
INPUT_PULLUPmode to eliminate the external resistors.
ပစ္စည်းများ
8- SparkFun Inventor's Kit - V3.210% ကော်မရှင်1 အစုံ$105.94
- မှစ၍$1.19
- မှစ၍$9.50
- မှစ၍$4.16
- မှစ၍$27.06
- 1 ခုနေရာယူပစ္စည်း
- မှစ၍$1.19
လိုအပ်သော ကိရိယာများ
1- နေရာယူပစ္စည်း
CC0 အများပိုင်
ဤအစီအစဉ်ကို CC0 အောက်တွင် ထုတ်ဝေထားသည်။ ခွင့်ပြုချက်မလိုဘဲ ကူးယူ၊ ပြင်ဆင်၊ ဖြန့်ဝေ နှင့် အသုံးပြုနိုင်သည်။
အစီအစဉ်မှတစ်ဆင့် ကုန်ပစ္စည်းများဝယ်ယူ၍ ဖန်တီးသူကို ပံ့ပိုးပါ ဖန်တီးသူ ကော်မရှင် ရောင်းချသူက သတ်မှတ်သည်၊ သို့မဟုတ် ဤအစီအစဉ်၏ ဗားရှင်းအသစ်ဖန်တီး၍ ဝင်ငွေခွဲဝေရန် သင့်အစီအစဉ်တွင် ချိတ်ဆက်မှုအဖြစ် ထည့်သွင်းပါ။