Introduction: Taking a Still Picture With a Raspberry Pi
How to take a still picture with a Raspberry Pi
Step 1: Obtaining Materials
You will need:
- Camera with ribbon cable to attach to Raspberry Pi Raspberry Pi (see image)
- HDMI cord to plug in
- 5 volt 2 amp power charger
- Mouse and keyboard
Step 2: Setting Up Raspberry Pi
- Pick up power cord
- Plug into outlet in wall Take other end to plug into Raspberry Pi outlet (see image)
- Pick up HDMI cord
- Plug one end to the monitor provided in classroom
- Plug other end into Raspberry Pi HDMI port (see image)
- Pick up mouse and keyboard wireless USB plugin
- Make sure the “Dell” writing on the USB plugin is facing up (see image)
- Plug in USB plugin to USB port of Raspberry Pi (see image)
Step 3: Connecting the Camera
- Find camera port tabs on Raspberry Pi
- Pull up camera port black tabs on Raspberry Pi
- Tabs will be on left and right side of camera port (See image 1)
- Take camera ribbon cable to plug into the camera port
- Ensure metallic strips on ribbon cable face HDMI port on Raspberry Pi (See image 2)
- Plug in ribbon cable into port
- Ensure that metallic strips are pushed all the way down into port
- Push down tabs on camera port to secure ribbon cable
- There will be a small “click” when port tab is pushed down
Step 4: Turning on Raspberry Pi
- Find power cord
- Find on/off button on cord
- Press button to activate
- Let system load until raspberry pie appears
Step 5: Enabling the Camera
- Click Raspberry Pi home button. (See image)
- Hover over Preferences Tab
- Click Raspberry Pi Configurations Tab
- Click Interfaces Tab on new menu
- Click enable bubble for the first Camera option
- Click the 'okay' option
- Click 'Yes' when asked to reboot
Step 6: Open Up Programming Application 'Thonny Python IDE'
- Click Raspberry Pi home button
- Drop down menu will appear (See image)
- Hover over Programming tab
- Another drop down menu will appear (See image)
- Select Thonny Python IDE from list (See image)
- Will open programming application
Step 7: Typing the Code
- Code needs to be typed EXACTLY AS WRITTEN
- Click within white textbox (See image for following instructions)
- Type first line “from picamera import PiCamera”
- Hit Enter for new line
- On next line type “from time import sleep”
- Hit Enter again
- Next line type “camera = PiCamera()”
- Hit Enter again for a new line
- Next line type “camera.rotation = 180”
- Hit Enter again for a new line
- Next line type “try:”
- Hit Enter again Line will automatically TAB
- Then type “camera.start_preview()”
- Hit Enter again
- Next line type “sleep(5)”
- Hit Enter again
- Next line type “camera.capture(‘/home/pi/Desktop/cameraTestImage.jpg’)”
- Hit Enter again
- Next line type “sleep(2)”
- Hit Enter again
- Press the Backspace button on your keyboard to remove this automatic tab.
- Next line type “finally:”
- Hit Enter again
- Next line type “camera.stop_preview()”
- Hit Enter again
- Next line type “camera.close()”
- Click File in the top left of the application
- This will open a drop down menu
- Click Save As... from the menu
- This will open a popup menu
- Name your program “cameraTest” in the text box marked “file name:”
- Press the Save button.
Step 8: Taking the Picture
- Click the Green Arrow button in the application to run the program and take a picture! (See image)
- If you had an error when taking the picture, first double check that your code is exactly as in the picture.
- If it is not, make sure it is exactly the same.
- If you still have an error after double checking your code is the same, ensure that you completed step 5 to enable the camera.
Step 9: How to Open Picture
- File will appear on homescreen to the left of open Thonny program if you saved it to the desktop
- File will be named “cameraTest”
- Double click file to open