Introduction: Arduino Basics: Making a Locking Mechanism
Designed for High School Students
The Arduino is a simple and adaptive tool that can be used across multiple project types from simple to complex. This lesson will bring you through the basics of the Arduino, its components, wiring, and coding in order to complete a simple project and edit it's code.
The project for this lesson uses a servo and a keypad in order to create a locking mechanism. This simple project can be easily attached to a box or other container for security purposes.
This Instructable Addresses:
Core Concepts
Nature and Characteristics of Technology and Engineering
Technology and engineering require knowledge of the outside world, both natural and human. It is an interdisciplinary field, and it involves the ability to understand, use, assess, and create technological systems and ways of thinking.
Integration of Knowledge, Technologies, and Practices
Technology and engineering are interdisciplinary. They are impacted by the transfer of knowledge from one field to another. This causes advancements in the field and for the field to move forward and grow. This includes connections beyond just design and delves into business and copyright aspects. This project has students crossover and use their knowledge of electronics, design, and technology to create one final product.
Design in Tech. and Engineering Education
Design is fundamentally human. Purpose driven decision making within set criteria and constraints coupled with creativity is a very human process. In most cases, there is not one perfect solution, leading to the ability and need to iterate and optimize the things we create. This design process is based around a set of skills that allows for the use of fundamental design principles that allows for us to create tangible solutions to problems. This creation process is at the core of technology and engineering education. When creating the locking mechanism< students push think about their design when placing the LED lights, leads, and wires.
Practices
Making and Doing
The act of creating (making) and the hands-on processes we use to create (doing) are at the core of technology and engineering education. This practice is not about just creating an end product, but it requires the development of industrial skills and knowledge. By making and doing, students foster higher order design based thinking which aids students in the five types of models used in technology and engineering education.
Critical Thinking
Critical thinking is an important skill for students both inside and outside of the classroom. In order to further foster critical thinking in technology and engineering education, students should be asked to make decisions that require judging the value and accuracy of information and make educated conclusions based on those judgements. This can be done through solving ill defined real world problems where they must systematically look for proper solutions through critical thinking. While suitable for beginners, this project does require problem solving and critical thinking if it does not work the first time. Students must also use their critical thinking skills while putting together and organizing the locking mechanism.
Learning Objectives
By the end of this lesson, you will be able to:
- Identify an Arduino and its basic components
- Understand the basics of circuitry
- Be able to use the Arduino launcher
- Understand the basics of wiring and wire a simple project
- Use a wiring schematic to attach a component
Supplies
For this project:
- 1 Arduino Elegoo Uno R3 with USB
- 1 Breadboard
- 1 Computer with USB access
- 2 220k OHM resistors
- 15 Male to male wires
- 2 LED lights
- 1 Keypad
- 1 Servo
If you wish to explore the Arduino more beyond this project, the ELEGOO UNO Project Super Starter Kit with Tutorial is a great option available here. It contains most of the materials needed for this project and includes a great set of parts to help you get started.
Cost Estimate: Though prices go up and down, you should be able to complete this project for around $25-$30
Step 1: The Arduino: Parts/Relevant Vocabulary
Though the Arduino may seem intimidating, for the purpose of this project you only need to know its most basic terms.
The Arduino: An Arduino is an easy to use piece of equipment and software. It includes both a circuit board, inputs, and a microcontroller. This makes the Arduino an excellent platform for those just starting out with electronics.
The Microcontroller: You will not need to do anything physically with the microcontroller, but it is essential in making the Arduino work.
The Input Pins: These are the pins used to attach or "plug in" your components to the Arduino. If you look at the pins above, each one has a corresponding number. This number will be later used in the code in order to make each of our components work.
Ground/Power Pins: These pins allow for you to connect to ground (labeled GND) and power (labeled 5V, for 5 Volts of power)
The Reset Button: The reset button cuts off and reconnects your Arduino to the power supply. This will clear the current code stored on the Arduino, and it will wait for new code to be uploaded.
Step 2: Lets Get Started: LED Lights/placing Components Into the Breadboard
The first step in our project is to set up our LED lights. LED lights contain two leads: one positive and one negative. The easiest way to tell which is which is to look at the lead length.
The longer lead is positive the smaller lead is negative.
- With the longer, positive lead facing right, place the green LED on your breadboard as seen in GIF 1 above.
- With the longer, positive lead facing right, place the red LED on your breadboard to the right of the green LED as seen in GIF 2 above.
Components should be pushed into the breadboard until they feel securely clamped in place
Step 3: Setting Up the Power Rails
Next we need to set up our breadboard Power Rails as seen in the image above.
For ease of wiring, a red male to male wire is typically used for power, and a black wire is used for ground.
- Take 1 Male to Male wire and place one end in the positive (+) power rail and the other end into the 5V Powerinput on your Arduino
- Take 1 Male to Male wire and place one end in the negative (-) power rail and the other end into the Ground (GND) Power input on your Arduino
Step 4: Wiring the LEDs
In order to wire our LED lights, we need to both connect the LEDs to power and use a resistor to connect them to ground. The resistor helps to regulate the power output. Without the resistor, too much power will flow through the LED and it will destroy its internal components.
Connecting Your 220k OHM Resistors:
Unlike the leads on the LED, resistor leads do not have directionality. As long as you are connecting one end to the left ground lead on the LED and the other to the ground (-) power rail the resistor will work. See Picture 1 and GIF 1 above
Connecting Your LEDs to Power:
To connect to power you simple take a male to male wire and plug it in below the right lead of each LED. Next take the right LED wire and plug it into input 11 on your Arduino. Then the take the left and plut it into input 12
Now if you plug your Arduino into your computer, both LED lights should light up.
Step 5: The Servo
Now that our LEDs are ready to go we will wire the servo.
Servo wiring is simple as there are only 3 wires needed:
The orange which connects our component to input 11 on the Arduino
The red which connects to the positive power rail
The brown which connects to the negative ground rail
Use the male to male wires to connect each servo port to the breadboard and the Arduino
Step 6: Attach a Keypad Using a Wiring Diagram
When attaching electronics, using a wiring diagram can be a helpful and easy tool to set up your components. Just look at the diagram and attach male to male wires from the component to the Arduino inputs as shown.
Attach the keypad using the diagram above.
Step 7: Uploading Code
Now that the wiring is done its time to use the Arduino software to upload the code to the Arduino. Click below to download and open the code
If you do not yet have the software, you can download it from Arduino website here
Attachments
Step 8: Plug and Chug
The code is open now lets run it:
- Plug in your Arduino to your usb port
- Before you run the code, go to Tools, then Port, then select the usb port you have plugged into (See image 1)
- Check your code: Click the check at the top of the screen. You should see the message "done compiling" below (See image 2)
- Run your code. Click the right facing arrow next to the check. (image 3)
The red light should turn on. Type in the password '123' on the keypad, the servo should turn, and the green light should turn on. To engage the lock again, press the '#' key
Congrats! You've made the locking mechanism
Step 9: Final Product
Step 10: Troubleshooting
Lights aren't turning on? Check to be sure the power rail has been set up correctly, and that the leads on the LED lights are facing the right way.
Servo won't move or keypad isn't working? Check your wiring. Are all of the pins fully pushed into the breadboard and the components? Did you misplace any wires when connecting?
Step 11: Take It Apart
Once you've made the lock you can take it apart.
Unplug your Arduino first!
Once you've disconnected the Arduino just pull all of the male to male wires out along with the LED lights and the 220k OHM resistors.