Through this lesson, students will learn how to apply programming concepts such as conditional statements and condition tests to create security measures, in the form of a PIN-controlled lock. However, instead of entering in a traditional PIN using a keypad or touchscreen, the PIN consists of an RGB light combination, represented by an RGB LED, and controlled using potentiometers.
At a Glance
- Age Level: 12-14 years old, 15-18 years old
- Subjects: Computer Science/Computer Programming
- Time Needed: 3 weeks (approximately 1,000 minutes of class time)
Students will be able to:
- Demonstrate proficiency in using conditional statements
- Read and process input information
- Use input for condition tests
- Write conditional statements with Boolean logic (AND, OR)
- Discuss how input tolerances can affect the usefulness and reliability of the program
- Describe how computer screen pixels can be millions of different colors by mixing red, green, and blue light
- Create a PIN-protected lock
Computer Science I (§126.33)
2.E improve numeric display by optimizing data visualization
4.F design a solution to a problem
4.H identify and debug errors
4.I test program solutions with appropriate valid and invalid test data for correctness
4.S develop algorithms to decision-making problems using branching control statements
4.V demonstrate proficiency in the use of logical operators
How can we, as electrical and software engineers, develop unique and secure PIN-based security systems for personal and business use?
Brainstorm and interact with different PIN-entry systems (keypads, voice-controls, fingerprint scanners, retinal scanners, music-based locks, pattern locks, etc.). Discuss the benefits and drawbacks of each type.
Build a lock that is controlled by the color of an LED, using potentiometers as dials to adjust the red, green, and blue light intensities.
Discuss the benefits and drawbacks to this system. Discuss how realistic the implementation of this system would be for personal use versus corporate use.
Reflect on what was learned in this project, and how those skills can be transferred to future projects. Reflect on how this project could be built upon to improve either its ease of use, or its security.
No prior knowledge is required for this project to be useful or meaningful.
English Language Learners
Provide a list of defined terms; provide a code template for the project.
Special Education Students
Provide a code template for the project; reduce the project to be the intensity of a single color of light, instead of a blend of three.
Gifted and Talented
Use the LCD screen to provide a digital read-out of the current LED red, blue, and green values; use a different system to provide input for the lock, such as the microphone for music.
Technology and Resources
Students will require the following:
Arduino 101 with programming cable
Computer with Arduino 101 software
1x RGB LED
3x 100-Ohm resistors
3x 10K trimmer potentiometers
1x servo motor
Working in pairs or small groups, students will build a briefcase with a lock installed, controlled by a servo motor. The servo motor will turn, unlocking the box, once the user has inputted the correct “code,” represented by the color of an RGB LED. The LED color can be adjusted by twisting three knobs mounted on the briefcase.
Summative – completion of the final working project; test on conditional statements.
Formative – verbal explanation or presentation of how the code works for the project, quizzes on conditional statements, occasional progress checks on how the project is coming along.
Additional Tips and Information
The inclusion of tolerances will be very important for making this a successful project. Requiring the PIN to be exactly correct (example, exactly 75-red, 148-green, 200-blue, as opposed to 80-red, 150-green, 200-blue being sufficient) will make the lock nearly impossible to open. However, making the tolerance window too wide will make the lock too easy to open. Students will need to balance this, likely through trial and error. (However, I’ve found a good tolerance to be +/-10-15).
Teacher, CTE Department
Energy Institute High School
Houston Independent School District
Houston, TX, USA
Students will learn how to apply programming concepts such as conditional statements and condition tests toward creating security measures, in the form of a PIN-controlled lock.