Tag Archives: #week4

WEEK4-combination lock

Description of the project:

The goal of this assignment is to build your own combination locker with led and buttons. For me, I want a combination locker which can use keypad numbers as input and can be controlled by my cell phone. So I choose to use 1Sheeld module and it’s application to build my own combination locker.

List of components:

  • 1sheeld– a wireless shield which can easily attach to Arduino, with the customized application, you can use your cell phone to control Arduino.
  • Arduino Uno x1
  • Breadboardx1
  • 200-ohm resistor x1
  • Red led x1
  • jumper wires

How it works:

first of all, attach the 1sheeld to Arduino, and then connect LEDs to the pin assigned. After uploading the code to Arduino and 1sheeld. You can open up Bluetooth to search 1sheeld and connect to it. Then open the keypad shield in the 1sheeld application, enter the password you set to open the lock. In this project, I used red led to indicate “the locker is not opened”, and it was set it to be lighted up as default. When the user enters the right password, the red light should be turned off.

In the code part, using flag function (in here I put “iterations” to represent it ) to set your password. I set the password to “1220”, and every time you press the right keypad the flag will plus one. After fulfilling the 4 iterations (0~3), the red led should turn off.

Because of the flag function, the four-digit password should be checked each time, the wrong input such as “4593”, “2340” will not let the red light go off. See the following code for the details:

Any problems you encountered and/or solved:

My original intention is to use two different led lights, a red one for wrong and a green one for right. But no matter how hard I tried, 1 sheeld seems to not able control two LEDs at all. What I tried to debug including change all the components including the breadboard, LEDs, wires, and different pin. In the end, I only use one led to represent the lock status.


Joyce’s Lock(week 4)


The goal of this project is to build a combination lock that uses 4 buttons and LEDs that indicates lock status.


red led x1

green led x1

blue led x1

button x4

resistor(200Ω) x4

resistor(10kΩ) x4

arduino board & breadboard


How it works

Users need to input a combination of 4 numbers to open the lock. The blue button is a reset light which will light up 5 seconds after the right code is input (The lock is locked again, the input is reset ) or the wrong four numbers are input (meaning please try again, the input is reset). The red light means a wrong code is pushed and the green light means the code is correct.

Code: https://github.com/joycemolly/pcomp–lock-combination/blob/master/homeworkLock.ino