Introduction: All-Seeing Pi
This will show you how to take pictures with different filters on the raspberry pi using the raspberry pi camera. Then you will use Twitter API to tweet the pictures.
Step 1: Installing the Soft Ware
First, you will need to install these two packages in the terminal window to access twitter and connect the buttons.
Step 2: Connecting the Button
You will need:
Raspberry Pi Camera Module
2 Male-female jumper leads
1 tactile button
Connect the button to the pi by putting one end of the wire in GPIO 23 and a ground pin (as seen in the picture), and plug the button into the bread board as seen in the picture. Then, plug the other end of the wires into the bread board in the same row as the button is plugged in.
Step 3: Connecting the Pi Camera
Connect the camera as shown above, then go into the Raspberry Pi configuration and enable the camera.
Step 4: Type the Beginning Part of the Code
First you will need to open up Thonny, then you will set up the switch statement with the beginning part of the code and print out the users options for filters. Then whatever number the user types in will be stored as variable var. Then import all the things you will need throughout the program. after that, there is a line that says camera=PiCamera() this will store the camera as a variable called camera. The def new picture and def tweet picture are setting up what will happen when someone presses the push button for new picture or tweet picture.
Step 5: Cases for the Switch Statement
Using this each number that someone types in will have a different filter assigned to it. As you can see they are all basically the same code except the effect. In the output=strftime you wan to put ("home/pi/wherever you want to save the picture") the part after will save the picture as the date and time you took it. Make sure you have the break after each case, or else it will only do the last case no matter what number is typed in.
Step 6: Last Part of the Code
This last part will allow you to take pictures with button, and create push buttons to take a new picture and tweet the picture. The last step is connecting the program to twitter.
Step 7: Connecting Twitter
First, you will need a twitter account, then you will need to got to apps.twitter and create a Twitter API . This may take a day or two to be approved. Once you are approved Your going to need the consumer key, consumer secret, access token, and the access token secret. Then make a new file called auth and put in the code above.
Step 8: Taking the Picture
When you've typed all the code run the module, and you should be able to take pictures with button. After you've taken the picture a gray screen should pop up with two push buttons one should say new picture and the other should say tweet picture. When you press tweet picture it will tweet it to the twitter account that you made the API on. Also, the image should show up where you set it up to save in the beginning with the date and time as the file name.
4 years ago
Fun PI project.