Electronics project for kids: How to learn Arduino programming with push-button controlled LED
Introduction
Howdy ! Welcome in our today's blog. It's your go-to source for all things related to projects for kids from basic level, to intermediate and advanced levels. We are dedicated to provide information and insightful content on how to do step wise and ensuring you can do it yourself using Arduino.
Circuit building is one of the most interesting topics, it will help you build your own gadget. This post is electronics for kids and will be demonstrating to you how to control an LED using push-button and Arduino. Starting from this point one can be able to create games later for kids later on using electronics.
Getting Basic understanding of Current and Resistance and Voltage
Current is flow of electrons in a wire, it flows and resistance resists. The Voltage pushes.
They all affect each other in the process of making electronics projects for kids.
There is an equation that govern the Current, voltage and resistance law called Ohm's law. No need to go into this for the tutorial.
Below is a demonstration of how current passes through a wire, the voltage pushes it then Resistor tries to resist, all this is in electronics and projects for kids, not limited, also circuit for adult who is starting.
Required Materials
Arduino board
Breadboard
Jumper wires
LED
Tactile push-button - momentary one
10k -ohm resistor
220 - ohm resistor
Switches, resistors and LEDs will be very instrumental for the rest of the projects we are going to cover for the electronics for kids.
How It Works
When the push-button is pressed it complete the circuit and hence turn ON the electronic circuit. Immediately you release the switch, the connection spring back and the LED goes OFF. This switch is highly applicable for laptop keyboards, game pads, among other appliances.
This switch has four pins, but you will realize that it has only two pins in use. See the circuit diagram below:
Building the circuit
Place your push-button in the breadboard.
From the circuit diagram of the push-button, connect pin A to one leg of 10k Resistor, and connect that same resistor leg to Arduino pin 3. Connect the other resistor leg to the GND rail and GND of Arduino to GND rail in the breadboard. Connect pin C to the +5V Rail, and connect the rail to +5V of the Arduino. (Any Arduino can do this project perfectly)
PUSHBUTTON | Arduino |
PIN A | GND and Pin 3 through 10k-ohm resistor |
PIN C | +5V |
3. Connect longer pin of LED to Arduino pin 13 through the 220 ohm- resistor and the shorter leg to the GND.
LED | ARDUINO |
Long Leg(positive) | Pin 13 through 220 -ohm Resistor |
Short Leg (Negative) | GND |
To verify that your setup is well connected as explained, see the Arduino LED, push-button circuit below, make sure you connect exactly as it is shown for this electronic project.
The Sketch / The code
This is an Arduino code, Pin 3 is assigned to push-button and Pin 13 to LED. We have to assign the button a state which should be state 0 in the code.
const int button = 3; //Assign a button pin
const int ledpin =13; //Assign LED a pin
int buttonstate = 0; //Give a button a state
void setup()
{
pinMode(ledpin, OUTPUT); //Set led Pin as Output
pinMode(button, OUTPUT); //Set pushbutton Pin as input
}
void loop()
{
buttonstate = digitalRead(button); //read input in pin 2
if(buttonstate == HIGH){
digitalWrite(ledpin, HIGH); //turn LED On
}
else {
digitalWrite(ledpin, LOW); //otherwise turn it off
}
}
Open your Arduino IDE, copy and paste the code into it. Navigate to tools, and select Board type, if you are using Arduino Uno, select it, if you are using Arduino Mega 2560, select it. On tools select the correct port assigned to your board.
Actual Circuit Connection
Video Demonstration
This is the video demonstration for the working project
Need to explore more?
You can add more LEDs and push-buttons in the circuit, by following the same procedure, all you need to do is make slight changes in the code.
e.g. let say you want to add another push-button and LED, you will define other pins as: say you want to connect a button in pin 2, led in pin 12 and call it ledpin2 and buttonstate2 as zero.
const int button = 2; //Assign a button pin
const int ledpin2 =12; //Assign LED a pin
int buttonstate2 = 0; //Give a button a state
For this to work, you have to define your pins in setup as OUTPUT and also manipulate your code accordingly in void loop() of Arduino IDE.
Do not be worried if this is confusing we shall be building more circuits on how to control multiple LEDs with Multiple push-buttons for Electronics for kids.
Conclusion
Congratulations ! You have successfully built an Arduino push-button controlled LED project for basic circuit. Like this post, share widely and can follow us in our social media platforms. In case you have any topics you wanna suggest, leave a message in comment section.
Newsletter, follow, subscribe and like the social medias
If you like online STEM activities, consider to subscribe to the newsletter and Social medias for updates and don't miss any STEM event. Don't forget to subscribe to the newsletter at the bottom of our website ''www.makersgeneration.net'' for more events, tutorials and freebies.
Subscribe to the Facebook group if you have yet registered. Content and tutorials are shared daily: Create and build STEM project for kids
We can be reached at: contact@makersgeneration.net if any questions.
See you on soon.
Comments