<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>The Raspberry Pi Camera</title><link>https://community.element14.com/products/raspberry-pi/w/documents/19622/the-raspberry-pi-camera</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>The Raspberry Pi Camera</title><link>https://community.element14.com/products/raspberry-pi/w/documents/19622/the-raspberry-pi-camera</link><pubDate>Mon, 10 May 2021 20:51:12 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:d69a0263-63fc-4c0f-b710-238faf1c6781</guid><dc:creator>biglesp</dc:creator><comments>https://community.element14.com/products/raspberry-pi/w/documents/19622/the-raspberry-pi-camera#comments</comments><description>Current Revision posted to Documents by biglesp on 5/10/2021 8:51:12 PM&lt;br /&gt;
&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;a href="https://farm8.staticflickr.com/7650/16992757006_de6faf7402_o_d.jpg"&gt;&lt;img alt="16992757006_de6faf7402_o_d.jpg" class="jive-image image-4" src="https://farm8.staticflickr.com/7650/16992757006_de6faf7402_o_d.jpg" style="height:465px;width:620px;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;The &lt;strong&gt;&lt;span&gt;&lt;span class="e14-init-shown" id="addProduct-RAVDkQpo-linked" style="white-space:nowrap;"&gt;&lt;a class="jive-link-product-addtolist" href="https://www.element14.com/community/view-product.jspa?fsku=2302279&amp;amp;nsku=69W0689&amp;amp;COM=noscript" target="_blank"&gt;&lt;span class="pf-widget-map pf-productlink-cart-icon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;a class="jive-link-product pf-embedded-product-link" href="https://www.element14.com/community/view-product.jspa?fsku=2302279&amp;amp;nsku=69W0689&amp;amp;COM=noscript" target="_blank"&gt;Raspberry Pi camera&lt;/a&gt;&lt;/span&gt;&lt;span class="e14-init-hidden" id="addProduct-RAVDkQpo-unlinked"&gt;Raspberry Pi camera&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt; is an awesome piece of kit and can really liven up your next project. But how can you get started with it? Well let’s grab a camera, &lt;a class="jive-link-external-small" href="http://www.element14.com/community/community/raspberry-pi/raspberrypi2" target="_blank"&gt;&lt;strong&gt;Pi 2&lt;/strong&gt;&lt;/a&gt; and a few cheap components and build three projects based on the camera.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;a href="https://farm8.staticflickr.com/7620/17017297212_127fb3e02e_o_d.jpg"&gt;&lt;img loading="lazy" alt="17017297212_127fb3e02e_o_d.jpg" class="image-5 jive-image" src="https://farm8.staticflickr.com/7620/17017297212_127fb3e02e_o_d.jpg" style="height:465px;width:620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;h1&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span style="font-size:18pt;"&gt;Setup&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h1&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Installing the camera is quick and easy and to start the installation firstly you will need to locate the black connector marked CAMERA between the HDMI and Ethernet ports.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Carefully lift the top and bottom edges of the connector vertically, they will gently slide up and then stop when in place. Be careful as the CAMERA connector is rather fragile, you will only need to use a little pressure on the connector.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Remove your camera from the box and slide the ribbon connector into the CAMERA connector, ensure that the blue edge faces the ethernet port. Be careful handling the camera it is rather fragile and sensitive to static. With the ribbon inside the connector gently push the connector edges back down, locking the ribbon in place.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;padding:0px;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;&lt;a href="https://farm9.staticflickr.com/8743/16992755516_409baca2ea_o_d.jpg"&gt;&lt;img loading="lazy" alt="16992755516_409baca2ea_o_d.jpg" class="image-6 jive-image" src="https://farm9.staticflickr.com/8743/16992755516_409baca2ea_o_d.jpg" style="height:465px;width:620px;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;With the camera in place, boot up your Raspberry Pi and from the desktop open LXTerminal and type the following&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;At the menu navigate to Enable Camera and press enter. In the next screen select Enable, and then navigate to Finish, which will prompt you to reboot your Raspberry Pi. Do this and allow the Pi to reboot, thus enabling your camera.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;With the camera enabled we next need to check that it has been configured correctly and to do that we use the command raspistill in&amp;nbsp; LXTerminal.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;This will launch the camera and show a preview on the screen for a few seconds, compose yourself and it will take the picture. You can then open the picture via the file manager. It should be in /home/pi or in the directory where you used the command. If this does not work, check that you have connected the camera correctly and that raspi-config shows the camera as enabled. Remember do not remove the camera from the connector while the Raspberry is on, it will cause damage to the camera.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;For the last setup step we shall install the Python PiCamera libraries so that we can hack the camera using Python. &lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;br /&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;In LXTerminal issue the following command&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:Arial;font-size:15px;line-height:1.5em;"&gt;Once this is complete in LXTerminal type&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-family:Arial;font-size:15px;line-height:1.5em;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:Arial;font-size:15px;line-height:1.5em;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-family:Arial;font-size:15px;line-height:1.5em;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;h1&gt;&lt;span style="line-height:1.5em;color:#000000;font-size:18pt;font-family:Arial;"&gt;Project 1 - Take a picture with Python&lt;/span&gt;&lt;/h1&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="line-height:1.5em;color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="line-height:1.5em;color:#000000;font-size:15px;font-family:Arial;"&gt;Our first project is rather simple but it shows how to use the PiCamera library and gives us a quick introduction to the library.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="line-height:1.5em;color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;h3&gt;&lt;span style="line-height:1.5em;color:#000000;font-size:15px;font-family:Arial;"&gt;What will you need?&lt;/span&gt;&lt;/h3&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;&lt;span&gt;&lt;span class="e14-init-shown" id="addProduct-VmsNBhuX-linked" style="white-space:nowrap;"&gt;&lt;a class="jive-link-product-addtolist" href="https://www.element14.com/community/view-product.jspa?fsku=2461029&amp;amp;nsku=38Y6467&amp;amp;COM=noscript" target="_blank"&gt;&lt;span class="pf-widget-map pf-productlink-cart-icon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;a class="jive-link-product pf-embedded-product-link" href="https://www.element14.com/community/view-product.jspa?fsku=2461029&amp;amp;nsku=38Y6467&amp;amp;COM=noscript" target="_blank"&gt;Raspberry Pi 2&lt;/a&gt;&lt;/span&gt;&lt;span class="e14-init-hidden" id="addProduct-VmsNBhuX-unlinked"&gt;Raspberry Pi 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;span class="e14-init-shown" id="addProduct-RF7WlnCE-linked" style="white-space:nowrap;"&gt;&lt;a class="jive-link-product-addtolist" href="https://www.element14.com/community/view-product.jspa?fsku=2302279&amp;amp;nsku=69W0689&amp;amp;COM=noscript" target="_blank"&gt;&lt;span class="pf-widget-map pf-productlink-cart-icon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;a class="jive-link-product pf-embedded-product-link" href="https://www.element14.com/community/view-product.jspa?fsku=2302279&amp;amp;nsku=69W0689&amp;amp;COM=noscript" target="_blank"&gt;Raspberry Pi Camera&lt;/a&gt;&lt;/span&gt;&lt;span class="e14-init-hidden" id="addProduct-RF7WlnCE-unlinked"&gt;Raspberry Pi Camera&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;At this time the application has opened the shell, where we can issue commands / test logic on a line by line basis. We really need to be in the editor, so click on File and New Window to launch an editor window.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;As soon as the editor window is open, click on File and Save and name the file, anything BUT camera.py This is a good practice to get into as it means that any subsequent saves are handled quickly.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;So we start our code by importing two Python libraries.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Time - To control the speed of our project&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;PiCamera - To use the camera with Python&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;So with the libraries in place we now turn our attention to creating the main body of code. We start by using&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;To rename the picamera library into something more manageable, in this case “camera”.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Then we create a preview of the image, in the same way that your mobile phone shows a preview of the scene before the image is taken. This preview stays on screen for 5 seconds before capturing the image to the Desktop, and lastly the preview window is closed, ending the project.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;When ready, save the code as project1.py and then click on Run &amp;gt;&amp;gt; Run Module.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;The code will start a preview of the picture to be taken, wait 5 seconds so you can compose yourself and then take the picture saving it to the desktop. Then the preview will end.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;When the camera is active, you will see the red light illuminate in the corner of the board.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;So how did your picture come out? Was it upside down? Too dark or light?&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Well PiCamera has a few features that can be tweaked.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Rotation - You can easily rotate an image in 90 degree segments by using&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;camera.rotation = 180&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;This will flip the image upside down.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Saturation - Add more or less color to your picture, values can be between -100 and 100&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;camera.saturation = 50&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Brightness - Tweak your image if it is too dark or bright. Values are between 0 and 100&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;camera.brightness = 50&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Resolution - Create images at different resolutions. Values are entered by width and height, so an image 1920x1080 is 1920, 1080&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;br /&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;There are loads of tweaks that you can make and for the full list head over to Dave Jones’ great resource &lt;/span&gt;&lt;a class="jive-link-external-small" href="http://picamera.readthedocs.org/en/latest/index.html" rel="nofollow ugc noopener" target="_blank"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#1155cc;text-decoration:underline;"&gt;http://picamera.readthedocs.org/en/latest/index.html&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;h1 dir="ltr"&gt;&lt;span style="color:#000000;font-size:18pt;font-family:Arial;"&gt;Project 2 - Take a picture using a button&lt;/span&gt;&lt;/h1&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;h3&gt;&lt;span style="color:#000000;font-family:Arial;font-size:15px;"&gt;What will you need?&lt;/span&gt;&lt;/h3&gt;&lt;p dir="ltr" style="margin:0;font-size:13.3333330154419px;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;&lt;span&gt;&lt;span class="e14-init-shown" id="addProduct-sg8q028b-linked" style="white-space:nowrap;"&gt;&lt;a class="jive-link-product-addtolist" href="https://www.element14.com/community/view-product.jspa?fsku=2461029&amp;amp;nsku=38Y6467&amp;amp;COM=noscript" target="_blank"&gt;&lt;span class="pf-widget-map pf-productlink-cart-icon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;a class="jive-link-product pf-embedded-product-link" href="https://www.element14.com/community/view-product.jspa?fsku=2461029&amp;amp;nsku=38Y6467&amp;amp;COM=noscript" target="_blank"&gt;Raspberry Pi 2&lt;/a&gt;&lt;/span&gt;&lt;span class="e14-init-hidden" id="addProduct-sg8q028b-unlinked"&gt;Raspberry Pi 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;font-size:13.3333330154419px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;span class="e14-init-shown" id="addProduct-7Ky1P03L-linked" style="white-space:nowrap;"&gt;&lt;a class="jive-link-product-addtolist" href="https://www.element14.com/community/view-product.jspa?fsku=2302279&amp;amp;nsku=69W0689&amp;amp;COM=noscript" target="_blank"&gt;&lt;span class="pf-widget-map pf-productlink-cart-icon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;a class="jive-link-product pf-embedded-product-link" href="https://www.element14.com/community/view-product.jspa?fsku=2302279&amp;amp;nsku=69W0689&amp;amp;COM=noscript" target="_blank"&gt;Raspberry Pi Camera&lt;/a&gt;&lt;/span&gt;&lt;span class="e14-init-hidden" id="addProduct-7Ky1P03L-unlinked"&gt;Raspberry Pi Camera&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;&lt;span&gt;&lt;span class="e14-init-shown" id="addProduct-7UEnumWS-linked" style="white-space:nowrap;"&gt;&lt;a class="jive-link-product-addtolist" href="https://www.element14.com/community/view-product.jspa?fsku=1555982&amp;amp;nsku=95M4260&amp;amp;COM=noscript" target="_blank"&gt;&lt;span class="pf-widget-map pf-productlink-cart-icon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;a class="jive-link-product pf-embedded-product-link" href="https://www.element14.com/community/view-product.jspa?fsku=1555982&amp;amp;nsku=95M4260&amp;amp;COM=noscript" target="_blank"&gt;Push Button / Switch&lt;/a&gt;&lt;/span&gt;&lt;span class="e14-init-hidden" id="addProduct-7UEnumWS-unlinked"&gt;Push Button / Switch&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;&lt;span&gt;&lt;span class="e14-init-shown" id="addProduct-kZzfizXV-linked" style="white-space:nowrap;"&gt;&lt;a class="jive-link-product-addtolist" href="https://www.element14.com/community/view-product.jspa?fsku=2334487&amp;amp;nsku=88W3961&amp;amp;COM=noscript" target="_blank"&gt;&lt;span class="pf-widget-map pf-productlink-cart-icon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;a class="jive-link-product pf-embedded-product-link" href="https://www.element14.com/community/view-product.jspa?fsku=2334487&amp;amp;nsku=88W3961&amp;amp;COM=noscript" target="_blank"&gt;Breadboard&lt;/a&gt;&lt;/span&gt;&lt;span class="e14-init-hidden" id="addProduct-kZzfizXV-unlinked"&gt;Breadboard&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;Male to Female Jumper Wire x 2&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Before continuing please ensure that you have followed the above setup instructions.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Taking a picture at the touch of a button is something that we take for granted thanks to mobile phone technology and cheap consumer electronics. But in this project we will deconstruct the process and create our own push button camera using a few common electronic components.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;We start this project by attaching the hardware to the Raspberry Pi.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/1019x899/__key/communityserver-wikis-components-files/00-00-00-01-69/0066.contentimage_5F00_199693.png"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/01/69/0066.contentimage_199693.png-620x547.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=g6%2Bg9lLOy6P%2FVqBhtntPAqGvZMCddN5Emk1NBJD2LQE%3D&amp;amp;se=2026-05-06T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=NGWaNOgiy8pOkBhM+BhVjg==" style="max-height: 547px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;With the hardware attached our focus shifts to the code, more specifically the Python code that will power this project.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;To start open LXTerminal and type in the following, remember to press enter at the end of the line.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;This will open the Python 3 editor, commonly referred to as IDLE. At this time the application has opened the shell, where we can issue commands / test logic on a line by line basis. We really need to be in the editor, so click on File and New Window to launch an editor window.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;As soon as the editor window is open, click on File and Save and name the file, anything BUT camera.py This is a good practice to get into as it means that any subsequent saves are handled quickly.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;So we start our code by importing three Python libraries.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Time - To control the speed of our project&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;PiCamera - To use the camera with Python&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;RPi.GPIO - To use the GPIO pins with Python&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;With the libraries added, save your work before progressing.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;Next we setup the GPIO, firstly we configure the pins to use the Broadcom pin mapping (see diagram) which is not a logical layout, rather it breaks out the pin numbering from the Broadcom System on a Chip (SoC) that powers the Pi.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;We use a variable to store the pin number on to which our push button is connected.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;Then we setup the button to be an input and to be set high, in other words turned on at the start of the project.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;We now create an infinite loop to constantly look for the button to pressed and when that happens the camera code is launched.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;Now we make a few configuration changes to the camera settings, firstly changing the resolution, and then the saturation and brightness.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;Now we have the button detection code, this will look for a change to the GPIO pin attached to the button and when the pin goes from high to low the preview screen will come to life, wait for 5 seconds and then capture your photo before closing the preview and waiting for another button press.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;With the code complete, save it as project2.py and then go to Run &amp;gt;&amp;gt; Run Module. Wait a few seconds and then press the button to trigger the camera to life. Project 2 is complete.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;h1 dir="ltr"&gt;&lt;span style="color:#000000;font-size:18pt;font-family:Arial;"&gt;Project 3 - Take a picture using Minecraft&lt;/span&gt;&lt;/h1&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;&lt;a href="https://farm9.staticflickr.com/8735/16747589098_dd81522fc8_z_d.jpg"&gt;&lt;img loading="lazy" alt="16747589098_dd81522fc8_z_d.jpg" class="image-2 jive-image" src="https://farm9.staticflickr.com/8735/16747589098_dd81522fc8_z_d.jpg" style="height:349px;width:620px;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;h3&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;What will you need?&lt;/span&gt;&lt;/h3&gt;&lt;p dir="ltr" style="margin:0;font-size:13.3333330154419px;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;&lt;span&gt;&lt;span class="e14-init-shown" id="addProduct-YnwyEsSv-linked" style="white-space:nowrap;"&gt;&lt;a class="jive-link-product-addtolist" href="https://www.element14.com/community/view-product.jspa?fsku=2461029&amp;amp;nsku=38Y6467&amp;amp;COM=noscript" target="_blank"&gt;&lt;span class="pf-widget-map pf-productlink-cart-icon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;a class="jive-link-product pf-embedded-product-link" href="https://www.element14.com/community/view-product.jspa?fsku=2461029&amp;amp;nsku=38Y6467&amp;amp;COM=noscript" target="_blank"&gt;Raspberry Pi 2&lt;/a&gt;&lt;/span&gt;&lt;span class="e14-init-hidden" id="addProduct-YnwyEsSv-unlinked"&gt;Raspberry Pi 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;font-size:13.3333330154419px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;span class="e14-init-shown" id="addProduct-P8hRKZnf-linked" style="white-space:nowrap;"&gt;&lt;a class="jive-link-product-addtolist" href="https://www.element14.com/community/view-product.jspa?fsku=2302279&amp;amp;nsku=69W0689&amp;amp;COM=noscript" target="_blank"&gt;&lt;span class="pf-widget-map pf-productlink-cart-icon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;a class="jive-link-product pf-embedded-product-link" href="https://www.element14.com/community/view-product.jspa?fsku=2302279&amp;amp;nsku=69W0689&amp;amp;COM=noscript" target="_blank"&gt;Raspberry Pi Camera&lt;/a&gt;&lt;/span&gt;&lt;span class="e14-init-hidden" id="addProduct-P8hRKZnf-unlinked"&gt;Raspberry Pi Camera&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Minecraft is not only a great game, it is also a great source of Pi projects, and here is a camera triggered in Minecraft that you can code in less than 30 minutes.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;For this project you will need to close any Python 3 windows that you may have open. Currently the Minecraft Pi API only works with Python 2.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;Then open LXTerminal and type the following.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Then click on File &amp;gt;&amp;gt; New Window to open a new editor window.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;We start as ever with importing the libraries that make this project possible.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Time - To control the speed of our project&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;PiCamera - To use the camera with Python&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;Mcpi - To link Python with Minecraft&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;Next we create a link between our Python code and Minecraft. We create a variable called “mc” and that stores “minecraft.Minecraft.create()”, so whenever we use “mc” it tells Python to replace it with the long string of text.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;So we now reach the main body of our code, this is the loop that will constantly check our position in the Minecraft world. So we start with the loop, a simple infinite loop called “while True” and we then create a variable called pos and store the player&amp;#39;s current position in the world.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;Now we create a conditional statement, that will check our current position and compare it to the a hard coded value, in this case checking that our location on the X axis&amp;nbsp; is -7.0 and when this is true a message is posted to the chat window before reusing the Python code that we wrote earlier to take a picture.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="color:#000000;font-size:15px;font-family:Arial;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Save your code as project3.py but do not run it yet. Navigate to the Raspbian menu and go to Games and select Minecraft Pi.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;padding:0px;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;&lt;a href="https://farm9.staticflickr.com/8746/16315205993_49ebc826f2_o_d.png"&gt;&lt;img loading="lazy" alt="16315205993_49ebc826f2_o_d.png" class="image-7 jive-image" src="https://farm9.staticflickr.com/8746/16315205993_49ebc826f2_o_d.png" style="height:349px;width:620px;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;padding:0px;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;After a few seconds Minecraft Pi will be on screen, go ahead and create a new game and then a new world. When the game starts you will be dropped near to the X Y Z coordinates 0,0,0. To move around use the W A S D keys, and to look use your mouse. Spacebar is used to jump. Get a feel for the controls and then head to -7.0, you can see your location as a co-ordinate in the top left of the window.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Once there, open the inventory by pressing E on your keyboard, then find the signpost tool and left click on it to use it. In the game world, drop a sign post to show where -7.0 is.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;padding:0px;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;&lt;a href="https://farm8.staticflickr.com/7628/16810526967_5e6f85c6e9_o_d.png"&gt;&lt;img loading="lazy" alt="16810526967_5e6f85c6e9_o_d.png" class="image-3 jive-image" src="https://farm8.staticflickr.com/7628/16810526967_5e6f85c6e9_o_d.png" style="height:349px;width:620px;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;padding:0px;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;With that done, press TAB on your keyboard to release the mouse from Minecraft and navigate back to our Python code. Click on Run &amp;gt;&amp;gt; Run Module to start the project. Navigate back to Minecraft, the easiest way is to click on the window to bring it into focus.&lt;/span&gt;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;Now move to -7.0 again and the camera should spring into life!&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;So there we have it. Three projects all using the PiCamera in a different way. What can you do with the PiCamera and the Raspberry Pi 2?&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir="ltr" style="margin:0;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt;All of the code for these projects can be found at &lt;/span&gt;&lt;a class="jive-link-external-small" href="https://github.com/lesp/Element14_PiCamera" rel="nofollow ugc noopener" target="_blank"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#1155cc;text-decoration:underline;"&gt;https://github.com/lesp/Element14_PiCamera&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&lt;span style="font-size:15px;font-family:Arial;color:#000000;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: raspberry_pi, raspberry_pi_2, raspberry-pi-2&lt;/div&gt;
</description></item></channel></rss>