Two Mini Project Using Raspberry PI
This is a fun electronics game in which LED’s glow in certain pattern and if you are successful in repeating the same pattern you move to the next level where one extra led will glow in comparison to previous state else you end up losing the game. This file guides through installation and usage of the project.
-
Install RPi.GPIO library for python:
$ sudo apt-get update $ sudo apt-get install rpi.gpio
- 5 LED's
- 5 Resistors 220 ohms
- 4 Push Buttons
- PIR motion sensor
- Jumper Wires
- Raspberry Pi 3
- Breadboard
- Connect pins 6,19,13,26 to ladder LEDS 1 to 4(Red,Yellow,Green,White) respectively.
- Connect GPIO pins 4,27,17,22 to corresponding switches 1 to 4.
- Connect GPIO pin 5 to PIR output probe.
- Connect GPIO pins for ground and Vcc(5V).
- Connect GPIO pin 9 to LED 5 which will remain on till the end of the script.(Reference LED)
The Required connection is showed in the diagram :
- Run python pimon.py for playing the game with switch.
- Start the game with Motion Sensor using Motion and LED no.5 will glow till script has ended.
- LED's will glow in certain pattern and according to the level.
- Now Input using switches/Push Buttons in the same way as LED's Glow (Memory).
- If you are successful you will move to the next level else Script will ask you to play again or end game.
In this part we are Converting the Binary Representation to Gray code Representation by glowing led in Gray code corresponding to its Binary Input.But, the fun part is that we are doing this by an Android app made by us.
On the raspberry pi, you should install these things.
-
Install RPi.GPIO library for python
$ sudo apt-get update $ sudo apt-get install rpi.gpio
-
Install Wiring pi $ sudo apt-get update
$ cd $ git clone git://git.drogon.net/wiringPi
-
Install apache and php
$ sudo apt-get install apache2 -y $sudo apt-get install php5 libapache2-mod-php5 -y
-
Remove the index.html file from /var/www/html by using this
$sudo rm index.html
-
Then you should have php script i.e index.php on your Pi in /var/www/html
Additional things .
2.An android phone. 3.Android studio on computer to put the app on the phone.
Screen Shot of Android Application :
####Components Used
- 4 LED's
- 4 Resistors 220 ohms
- Raspberry Pi 3
- Breadboard
- Jumper Wires
- Connect pins 6,19,13,26 to ladder LEDS 1 to 4(Red,Yellow,Green,White) respectively.
- Connect GPIO pins for ground.
Note : If you were successful in making the memory game mentioned above then you have no need to change any hardware connection ,just folllow the software part.
- Open the App.
- Type the IP of your Pi on the Edit Text Field. (To check Pi ip use ifconfig)
- Enter the Binary number whose gray code you want (ON-1/OFF-0).
- Press Find gray button to turn on the LED's.
- You will see the Gray code of your input on the circuit.
- Use reset Button to turn off all the LED's.