Penn students know that swiping a card and entering a four-digit pin after a night out is no easy task. Get it wrong a few times and a concerned security guard might call the Medical Emergency Response Team (MERT), causing embarrassment and a large fine.
What it does:
PinFaced has your back. ((We’ve developed an apparatus that enters your 4-digit code for you.)) It’s easy: swipe your card & enter. Our machine connects with your phone, receives your code via bluetooth, and pushes the buttons for you. After completing it's task, it sends an email to a designated friend that will come help you get to bed.
How I built it
There are two major sections part of our project: the Keypad and PinFaced. We will first describe the KeyPad and then PinFaced.
All the code and Solidworks files is in the Additional Links section. The files include the code for the Keypad Arduino, the PinFaced Arduino, and the Ethernet Arduino. The Solidworks files include the design for the Keypad and for PinFaced.
The Keypad contains a magnetic card reader, a 16-digit keypad, Bluetooth, LED indicators, and and Arduino Uno with a SparkFun breadboard shield. Each row and column of the 16-digit has a unique connector pin that is connected to the Arduino into a corresponding digital pin. When a digit is pressed, the row and column intersection represents a short and is read by the digital pin. The result can be viewed on the serial monitor. The yellow LED is normally on, but when a key is pressed, it blinks off. The green LED is normally off and blinks on when the correct 4-digit pin is entered. The LEDs are controlled by digital pins and are build on the breadboard shield. The Bluetooth portion contains a Master module used to send information to the PinFaced apparatus. This module is also connected to digital pins. Lastly, the magnetic card reader is connected to the computer and functions as a keyboard, inputting the card data into the Serial input of the Arduino’s Serial Monitor.
The code for the Keypad is publically available and it is important to examine in order to develop a technical understanding of the system. The 16-digit keypad has reference code on Arduino’s site that we conveniently incorporated in our code. This 16-digit keypad code simply printed the pressed key on the serial monitor. However, we have added many modifications to interpret the pressed key. Using Serial input functions, we have coded the Arduino to be able to read card data that was entered by the magnetic card reader. The Arduino is coded to take the specific digits from the card data that represent a Penn ID and search for a corresponding pin code using a pre-constructed “ID to Pin” map. Once the correct pin is found, it is displayed on the Serial monitor and sent to the slave Bluetooth on pin faced using btserial functions. Now the Keypad is looking for a sequence of four digits in the correct order and value that matches the pin. Once a set of 4 digits are entered, the Keypad check for a match. If there is a match, the code instructs the green LED’s digital pin to turn high. If there is not a match, the Yellow LED remains turned on. In both instances, the Keypad resets and is ready to accept another pin-entry or card-swipe, making it a fully functional Keypad that can be used in any industry or setting.
Now we will discuss the technical aspects of the PinFaced apparatus, beginning with the hardware and circuitry and then the code. The PinFaced, similar to the Keypad, sits in a box constructed by laser cut pieces press-fitted together. We used Solid Works to design both PinFaced and the Keypad. PinFaced has three tiers. The bottom tier is space for the Keypad. The middle tier contains the solenoids and circuitry for the solenoids, which is soldered on a perfboard. The top tier contains two Arduinos and a Bluetooth module.
The middle tier contains the actuators, which are the solenoids that press down on the Keypad depending on the pin that is passed to them. A solenoid is an electro-mechanical device that uses current to generate a magnetic field that pulls/pushes a metal piece. Each solenoid is controlled by a transistor circuit, resulting in ten repeated circuits on the perfboard. A transistor is needed to control an external power source using directions from electronic signals from the Arduino, so the transistor is functioning as an electronic switch. Solenoids require power external to that of the Arduino because the Arduino can only supply 40mA through its digital pins while the solenoids require 300-400mA depending on the solenoid. The circuit connects the digital pin to the gate of the transistor, thus controlling it. The drain of the transistor is connected to the ground of the solenoid and to the anode part of a diode, which has its cathode connected to the positive terminal of the external power supply in order to prevent back-emf generated by the movement of the solenoid and its creation of current. The source is connected to the positive terminal of the external power supply along with the positive end of the solenoid. This circuit is repeated ten times.
Next, we can examine the top tier of PinFaced, which contains two Arduinos. The first Arduino controls the solenoids and is connected to the slave Bluetooth that corresponds to the master in the Keypad. It uses the digital pins to open or close the transistor switch. It is also connected to the second Arduino and controls it by giving it a high voltage that triggers an action. The second Arduino is connected to Ethernet and sends an email to the user’s friend after a high voltage signal is received from the first Arduino.
Lastly, we will explain the code behind the Arduino that controls the solenoids. We coded the Arduino to wait for bt serial communication from the master module. Information is transmitted character by character, so we had to build a string and change it into an integer using the toInt function. Then, to parse out individual digits that would then call on digital pins to fire solenoids, we divided each digit by a power of ten, took the first integer, and kept the remainder to be cycled for the next iteration. The solenoids were then triggered to fire, the program was reset, and the Ethernet Arduino was activated. One problem that we had to solve was “bouncing,” where the solenoid, when fired, would bounce at micro levels and press the Keypad keys multiple times. We fixed this by implementing a “Debounce” code in the Keypad that created a delay after each key was pressed to null the subsequent presses.
Challenges I ran into
Discovering a method to transmit data between a card reader and the Arduino. Eventually, this was solved by using the IDE to send and receive serial data. The firing of the solenoids proved a little challenging as each one requires about 3V and .4amps of for a single activation.
Accomplishments that I'm proud of
As systems engineers, we are proud of our combination of software, electrical, and mechanical systems.
What I learned
We learned how to incorporate transistors to amplify the power that the solenoids received. We developed our skills in solidworks and increased our coding ability.
What's next for PinFaced
To be mass produced and used all over Penn's campus.
Promo video - https://www.youtube.com/watch?v=CALCoLMaXlk