DESIGN & TESTING

DESIGN

The first part of designing the project involved recreating the password login functionality that stems from the typical smartphone onto the Raspberry Pi. It will be using a series of PyGame functions to allow screen interactivity with the user. I wanted to make the screen as similar as possible to an actual passcode simulation, so I had the starting screen display numbers 1-9. From there, the screen contained a series of "levels" depending on whether or not the correct password was entered. The implementation of hitting buttons on the screen is similar to that of the screen display buttons in Lab 2. For each number pressed, I drew a black circle and a green circle, with black circles redrawn each time a number was pressed and a green circles for each consecutive button press. The user would have up to 5 attempts to get the correct password, which fittingly was 1-2-2-5. If all attempts were used and the passcode was still incorrect, the program would cease.

Once this first part of the code was complete, I had gone ahead and dealt with building the physical structure of the wooden house. To do this, I purchased 12 inch x 12 inch square panels, 0.5 inch x 0.5 inch wooden sticks, and wood glue from the Cornell Store. My initial schematic of the final product is shown in the first two pictures. The fully crafted structure of the house is displayed in the following picture. As shown, I left a slit in the front of the house to implement a door that would be opened and closed.






Once that structure had been completed, I connected several different red and green LED lights to the Raspberry Pi's GPIO pins through software connections. After conducting my own personal research, I found that there should be a maximum of 3 LEDs per GPIO pin in order to avoid shorting the current to each of the pins. I connected the LEDs to GPIO pins 5, 6, 13, 16, 19, 20, 21, and 26. Thus, I had 24 LED lights connected to the Pi around the house. I simply attached the LED breadboards to the inside roof of the house. The pinout connection diagrams and the actual final result of the LED connections are displayed in the following images.








Another part of the project design involved attaching a servo motor inside the house to latch open a door at the front of the wooden house. In terms of connecting it to a GPIO pin, I used GPIO pin 3 because the majority of the other pins were being used for the LED lights. Due to the fact that this project did not involve any I2C, it was permissible to use this specific pin. In order to power the servo itself, I attached a battery pack to the red power wire of the motor and connected the other black wire to GND on the Raspberry Pi. Finally, in terms of attaching the servo itself, I used a wheel to trigger smooth movement for the door and attached a leftover piece of wood using velcro and rubber bands to keep it secure. The schematic of this new servo wheel is shown as follows.



The final portion of the project involved video playback on the piTFT screen. The user would be able to play music when he or she presses the "Done With Lights" button on the screen, bringing him or her to a new screen solely displaying the "Play Music" button. Once pressed, the user would hear and see Mariah Carey's "All I Want for Christmas is You" playing. The implementation of this video playback is similar to that of the Big Buck Bunny video played in Lab 1. However, this mp4 had not been configured to fit the piTFT screen, so I had to convert and resize the video display and storage size using HandBrake, an open source video converter suggested by Adafruit. The link to this can be found on the References page.

In order to hear the video playback on the piTFT, I also utilized a speaker provided from lab and put it underneath the wooden house to begin playing once the proper button had been pressed. The following image displays how I assembled the speaker mechanism.



Once all of these different parts had been assembled, I had completed the project! The end result is shown through the following images. Happy Holidays!



TESTING

There were a few issues that came up as I progressed through my project. The first was that I did come across connecting LEDs to GPIO pins. Because the breadboards were relatively small and the Raspberry Pi pins were close together, I had some physical trouble with wiring. Also, I became aware of the Raspberry Pi not being able to send current to multiple LEDs, so I had to ensure that the Pi would not burn out by putting a 1k resistor for each pin. On top of this, I had another issue where a PWM signal would not turn off, specifically for the motor. My error here was that I put the call to the PWM signal inside a while loop, so I had to input a flag to only run one time. Another issue was that sometimes there were lags with screen display, so to fix this, I placed a time.sleep(0.02) so that the while loop would not consistently be running and checking for events. Finally, I noticed that the way my Raspberry Pi was positioned on top of the wooden house, the screen functionality was upside down. To counteract this, I used pygame.flip for screen blitting to show the screen properly.