Taking a Still Picture With a Raspberry Pi
by eng249sec001 in Circuits > Raspberry Pi
1444 Views, 1 Favorites, 0 Comments
Taking a Still Picture With a Raspberry Pi

How to take a still picture with a Raspberry Pi
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
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)
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
Turning on Raspberry Pi
- Find power cord
- Find on/off button on cord
- Press button to activate
- Let system load until raspberry pie appears
Enabling the Camera
.png)
- 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
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
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.
Taking the Picture
.png)
- 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.
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