<?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>Video 4: Your First Pi Project</title><link>https://community.element14.com/products/raspberry-pi/w/documents/16829/video-4-your-first-pi-project</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>Video 4: Your First Pi Project</title><link>https://community.element14.com/products/raspberry-pi/w/documents/16829/video-4-your-first-pi-project</link><pubDate>Mon, 10 May 2021 19:14:04 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:060ea7b1-ac79-4113-812e-0d39124f73bd</guid><dc:creator>kellyhensen</dc:creator><comments>https://community.element14.com/products/raspberry-pi/w/documents/16829/video-4-your-first-pi-project#comments</comments><description>Current Revision posted to Documents by kellyhensen on 5/10/2021 7:14:04 PM&lt;br /&gt;
&lt;p style="margin:0;"&gt;This is the fourth video in our 2013 five-part series &lt;a class="jive-link-wiki-small" href="/products/raspberry-pi/w/documents/1846/getting-started-with-pi-video-archive-for-raspberry-pi-2"&gt;Get Started With Pi&lt;/a&gt; for Raspberry Pi 2..&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;table cellpadding="0" cellspacing="0" style="border:1px solid #b8d7e5;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="border:1px solid #b8d7e5;padding:15px;"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td width="382"&gt;&lt;span&gt;&lt;a href="https://www.youtube.com/watch?v=5v-RBqVn7rg"&gt;www.youtube.com/watch&lt;/a&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style="padding-left:15px;vertical-align:top;"&gt;&lt;h3&gt;Episodes in this Series&lt;/h3&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;a class="jive-link-wiki-small" href="/products/raspberry-pi/w/documents/16828/video-1-unboxing-and-setting-up-the-peripherals"&gt;Video 1: Unboxing and Setting up the Peripherals&lt;/a&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p style="margin:0;"&gt;&lt;a class="jive-link-wiki-small" href="/products/raspberry-pi/w/documents/16827/video-2-exploring-the-raspberry-pi"&gt;Video 2: Exploring the Raspberry Pi&lt;/a&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p style="margin:0;"&gt;&lt;a class="jive-link-wiki-small" href="/products/raspberry-pi/w/documents/16826/video-3-getting-your-pi-online"&gt;Video 3: Getting Your Pi Online&lt;/a&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p style="margin:0;"&gt;&lt;a href="/e14/assets/legacy/raspberrypi/video4.gif"&gt;&lt;img alt="image" src="/e14/assets/legacy/raspberrypi/video4.gif" style="float:left;"  /&gt;&lt;/a&gt;&amp;nbsp; Your First Pi Project&lt;/p&gt;&lt;hr /&gt;&lt;p style="margin:0;"&gt;&lt;a class="jive-link-wiki-small" href="/products/raspberry-pi/w/documents/16806/video-5-exploring-accessories-and-projects"&gt;Video 5: Exploring Accessories and Projects &lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#007fac;font-size:12pt;"&gt;&lt;strong&gt;Using External Controls and your Pi&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;Although this project does require some programming, you don’t need to know how to program to follow along with this video.&amp;nbsp; The code you need is available for download below on this page.&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:#007fac;font-size:12pt;"&gt;&lt;strong&gt;GPIO Pins&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;table cellpadding="0" cellspacing="0" style="width:100%;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="/e14/assets/legacy/raspberrypi/GPIOpins.gif"&gt;&lt;img loading="lazy" alt="image" src="/e14/assets/legacy/raspberrypi/GPIOpins.gif"  /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="padding-left:8px;vertical-align:top;"&gt;You’ll need to take the Raspberry Pi out of its case to access the GPIO Pins.&amp;nbsp; GPIO stands for “General Purpose Input Output” and you’ll find this method of interacting with the Pi is used in a lot of projects that can be found on element14 in our &lt;a class="jive-link-external-small" href="http://www.element14.com/community/community/raspberry-pi/raspberrypi_projects?ICID=getstartpi-videodoc4-rpiproj" target="_blank"&gt;Raspberry Pi Projects&lt;/a&gt;.&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;GPIO pins are “generic” – they can be used as input or output devices – and can be controlled with programs running on your Raspberry Pi.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#007fac;font-size:12pt;"&gt;&lt;strong&gt;Pi Cobber Kit (Adafruit)&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;We’ll be connecting to the GPIO pins with a &lt;span&gt;&lt;span class="e14-init-shown" id="addProduct-wZLBGDbT-linked" style="white-space:nowrap;"&gt;&lt;a class="jive-link-product-addtolist" href="https://www.element14.com/community/view-product.jspa?fsku=2215039&amp;amp;nsku=44W3497&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=2215039&amp;amp;nsku=44W3497&amp;amp;COM=noscript" target="_blank"&gt;Pi Cobbler kit&lt;/a&gt;&lt;/span&gt;&lt;span class="e14-init-hidden" id="addProduct-wZLBGDbT-unlinked"&gt;Pi Cobbler kit&lt;/span&gt;&lt;/span&gt; – available on the element14 site from our friends at &lt;a class="jive-link-external-small" href="http://www.adafruit.com/" rel="nofollow ugc noopener" target="_blank"&gt;Adafruit&lt;/a&gt;.&amp;nbsp; The Pi Cobbler Breakout Kit has three main pieces:&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;table cellpadding="4" cellspacing="0" style="width:100%;border-width:1px;border-color:#333333;border-style:solid;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="border-style:solid;border-color:#333333;border-width:1px;"&gt;&lt;a href="/e14/assets/legacy/raspberrypi/26pinribboncable.gif"&gt;&lt;img loading="lazy" alt="image" src="/e14/assets/legacy/raspberrypi/26pinribboncable.gif"  /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="border-style:solid;border-color:#333333;border-width:1px;vertical-align:top;padding:6pt;"&gt;. . . a 26-pin ribbon cable&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="border-style:solid;border-color:#333333;border-width:1px;"&gt;&lt;a href="/e14/assets/legacy/raspberrypi/26pincabbleends.gif"&gt;&lt;img loading="lazy" alt="image" src="/e14/assets/legacy/raspberrypi/26pincabbleends.gif"  /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="border-style:solid;border-color:#333333;border-width:1px;vertical-align:top;padding:6pt;"&gt;. . . a connector that attaches to the ribbon.&lt;br /&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;The one pictured on the bottom connects to the PCB.&amp;nbsp; You can tell the difference because the one on the bottom has that little tab – that helps it line up properly on the PCB.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="border-style:solid;border-color:#333333;border-width:1px;"&gt;&lt;a href="/e14/assets/legacy/raspberrypi/pcbheaderground.gif"&gt;&lt;img loading="lazy" alt="image" src="/e14/assets/legacy/raspberrypi/pcbheaderground.gif"  /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="/e14/assets/legacy/raspberrypi/pcbheader5v.gif"&gt;&lt;img loading="lazy" alt="image" src="/e14/assets/legacy/raspberrypi/pcbheader5v.gif"  /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="/e14/assets/legacy/raspberrypi/pcbheader33v.gif"&gt;&lt;img loading="lazy" alt="image" src="/e14/assets/legacy/raspberrypi/pcbheader33v.gif"  /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="/e14/assets/legacy/raspberrypi/pcbheadernumberedpins1.gif"&gt;&lt;img loading="lazy" alt="image" src="/e14/assets/legacy/raspberrypi/pcbheadernumberedpins1.gif"  /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="/e14/assets/legacy/raspberrypi/pcbheadernumberedpins2.gif"&gt;&lt;img loading="lazy" alt="image" src="/e14/assets/legacy/raspberrypi/pcbheadernumberedpins2.gif"  /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="border-style:solid;border-color:#333333;border-width:1px;vertical-align:top;padding:6pt;"&gt;&lt;p style="margin:0;"&gt;. . . a PCB board&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;The PCB is printed with information about the pins that stick into the breadboard.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The labels show you which pins&lt;/li&gt;&lt;li&gt;Are Ground&lt;/li&gt;&lt;li&gt;Carry a 5.0 volt power supply (Use caution – 5.0 volt power can damage the Raspberry Pi)&lt;/li&gt;&lt;li&gt;Carry a 3.3 volt power supply&lt;/li&gt;&lt;li&gt;Can serve as input or output pins&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#007fac;font-size:12pt;"&gt;&lt;strong&gt;Adafruit Pi Dish&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="/e14/assets/legacy/raspberrypi/breadboard.gif"&gt;&lt;img loading="lazy" alt="image" src="/e14/assets/legacy/raspberrypi/breadboard.gif"  /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="padding-left:8px;vertical-align:top;"&gt;&lt;p style="margin:0;"&gt;The Adafruit Pi Dish includes this clear acrylic board, some mounting posts to hold the Pi securely in place and the breadboard itself.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;There’s &lt;a class="jive-link-external-small" href="http://www.youtube.com/watch?v=hSx9iAOXC4E&amp;amp;feature=player_embedded" rel="nofollow ugc noopener" target="_blank"&gt;a great video on the Adafruit site&lt;/a&gt; that shows how to assemble all the pieces.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;Some people call these solderless breadboards since you can connect a variety of things without having to solder them all together.&amp;nbsp; Each of these little holes in the breadboard is a socket where you can push in things like led lights, buttons or jumper wires.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;Breadboards have two columns of sockets in the middle – ours has one side labeled A through E and the other side labeled F through J.&amp;nbsp; All of the sockets in each row are “connected.”&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;On the outside of both edges are power rails – usually the blue line is used for ground and the red line is used for power.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#007fac;font-size:12pt;"&gt;&lt;strong&gt;Connect one End of the Ribbon Cable to the Pi and the other End to the Breadboard&lt;/strong&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;The ribbon cable has a white line down one side. (Black ones usually have a red line; grey ones usually have a red line.)&amp;nbsp; That line represents the side of the ribbon that should be connected to Pin one.&amp;nbsp; On the Pi – Pin one is in the corner of the board so plug in ribbon with the line on the corner.&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;a href="/e14/assets/legacy/raspberrypi/pins2_explodedlarge.png"&gt;&lt;img loading="lazy" alt="pins_explodedlarge.png" src="/e14/assets/legacy/raspberrypi/pins2_explodedlarge.png" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;strong&gt;Be careful – it can be plugged in backwards!&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;The other end of the ribbon cable has a little tab on it – that helps line it up and snap in to the PCB.&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:#007fac;font-size:12pt;"&gt;&lt;strong&gt;Plug the PCB into the Breadboard&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="/e14/assets/legacy/raspberrypi/PCBheader2.gif"&gt;&lt;img loading="lazy" alt="PCBheader.gif" src="/e14/assets/legacy/raspberrypi/PCBheader2.gif" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="padding-left:8px;vertical-align:top;"&gt;There are two rows of pins on the bottom of the PCB – each row has to be plugged in to a different column A-E or F-G on the breadboard.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#007fac;font-size:12pt;"&gt;&lt;strong&gt;Connect the Jumper Wires on the Breadboard&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;The ribbon has been disconnected in the photos below to better illustrate the wiring.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;table cellpadding="4" cellspacing="0" style="border:1px solid #333333;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="border:1px solid #333333;"&gt;&lt;a href="/e14/assets/legacy/raspberrypi/2pwrbreadboard.gif"&gt;&lt;img loading="lazy" alt="image" src="/e14/assets/legacy/raspberrypi/2pwrbreadboard.gif"  /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="border:1px solid #333333;padding-left:8px;vertical-align:top;"&gt;&lt;p style="margin:0;"&gt;First Power the board.&lt;/p&gt;&lt;p style="margin:0;"&gt;Find a pin labeled 3.3v and run a jumper wire from the row of pins in columns A-E with the power – or red rail on the same side (green wire).&lt;/p&gt;&lt;br /&gt;&lt;p style="margin:0;"&gt;Then find a pin labeled GND and run a jumper wire from that row of pins to the blue rail on the opposite side (orange wire).&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="border:1px solid #333333;"&gt;&lt;a href="/e14/assets/legacy/raspberrypi/3addconpin22.gif"&gt;&lt;img loading="lazy" alt="image" src="/e14/assets/legacy/raspberrypi/3addconpin22.gif"  /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="border:1px solid #333333;padding-left:8px;vertical-align:top;"&gt;Next, run a jumper wire from Pin 22 to any open row above (yellow wire).&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="border:1px solid #333333;"&gt;&lt;a href="/e14/assets/legacy/raspberrypi/5buttonclosecircuitwire.gif"&gt;&lt;img loading="lazy" alt="image" src="/e14/assets/legacy/raspberrypi/5buttonclosecircuitwire.gif"  /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="border:1px solid #333333;padding-left:8px;vertical-align:top;"&gt;&lt;p style="margin:0;"&gt;Next add the resistor from the same row as the yellow wire to the power rail.&lt;/p&gt;&lt;br /&gt;&lt;p style="margin:0;"&gt;Add the button in the center – spanning the gap between the two columns much like the PCB.&amp;nbsp; The bottom pins of the button should be on the same row as the yellow wire.&lt;/p&gt;&lt;br /&gt;&lt;p style="margin:0;"&gt;In the same row as the top pins of the button, add another wire to the blue (ground) line.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#007fac;font-size:12pt;"&gt;&lt;strong&gt;Now Power up your Raspberry Pi &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;The following strings are to be entered in LX Terminal.&amp;nbsp; Be sure your Raspberry Pi is connected to the Internet.&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:#007fac;font-size:12pt;"&gt;&lt;strong&gt;Updating and Upgrading&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;Remember, it&amp;#39;s always a good idea to keep your Raspberry Pi Operating System (in this case, Raspbian) up-to-date.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;table border="1" cellpadding="0" cellspacing="0" style="padding:6pt;background-color:#ffffff;" width="100%"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="border:1px solid black;padding:6pt;border:solid windowtext 1pt;" valign="top"&gt;&lt;p style="margin:0;width:140px;"&gt;&lt;span style="background:silver;"&gt;sudo apt-get update&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style="border:1px solid black;padding:6pt;border-left:none;border:solid windowtext 1pt;" valign="top"&gt;&lt;p style="margin:0;"&gt;This command downloads the latest version of the OS to your Pi – it may take a while, depending on your network speed.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="border:1px solid black;padding:6pt;border:solid windowtext 1pt;" valign="top"&gt;&lt;p style="margin:0;width:140px;"&gt;&lt;span style="background:silver;"&gt;sudo apt-get upgrade&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style="border:1px solid black;padding:6pt;border-left:none;border:solid windowtext 1pt;" valign="top"&gt;&lt;p style="margin:0;"&gt;This command installs the upgraded code (that you just downloaded above) on to your Pi. After you press enter, it will calculate how much space will be required for the new version.&amp;nbsp; It will say something like. . .&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;strong&gt;After this operation, xxxMB of additional disk space will be used.&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;strong&gt;Do you want to continue [Y/n]?&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;Press Y to continue.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#007fac;font-size:12pt;"&gt;&lt;strong&gt;Install Python Development Kit and the RPI.GPIO&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;table border="1" cellpadding="0" cellspacing="0" style="padding:6pt;background-color:#ffffff;" width="100%"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="border:1px solid black;padding:6pt;border:solid windowtext 1pt;" valign="top" width="29%"&gt;&lt;p style="margin:0;width:210px;"&gt;&lt;span style="background:silver;"&gt;sudo apt-get install python-dev&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style="border:1px solid black;padding:6pt;border-left:none;border:solid windowtext 1pt;" valign="top" width="71%"&gt;&lt;p style="margin:0;"&gt;Type this in to install the Python Development Kit&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="border:1px solid black;padding:6pt;border:solid windowtext 1pt;" valign="top"&gt;&lt;p style="margin:0;width:220px;"&gt;&lt;span style="background:silver;"&gt;sudo apt-get install python-rpi.gpio&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style="border:1px solid black;padding:6pt;border-left:none;border:solid windowtext 1pt;" valign="top"&gt;&lt;p style="margin:0;"&gt;Type this in to install the RPI.GPIO&lt;/p&gt;&lt;p style="margin:0;"&gt;. . . you’ll be prompted to enter “Y” to confirm the install&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#007fac;font-size:12pt;"&gt;&lt;strong&gt;Create the Python File&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;table border="1" cellpadding="0" cellspacing="0" style="padding:6pt;background-color:#ffffff;width:100%;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="border:1px solid black;padding:6pt;border:solid windowtext 1pt;" valign="top"&gt;&lt;p style="margin:0;width:195px;"&gt;&lt;span style="background:silver;"&gt;nano pi-audio-button.py&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style="border:1px solid black;padding:6pt;border-left:none;border:solid windowtext 1pt;" valign="top"&gt;&lt;p style="margin:0;"&gt;One way to create a Python file is to use nano - this command will open an editor screen.&lt;/p&gt;&lt;br /&gt;&lt;p style="margin:0;"&gt;Save these two files to a thumb drive (in Windows, right click link and select “Save target as. . .”):&lt;br /&gt;&amp;nbsp; &lt;a class="jive-link-external-small" href="http://www.element14.com/community/resources/statics/513455/pi-audio-button.py.txt?ICID=getstartedwpi-doc4" target="_blank"&gt;pi-audio-button.py.txt&lt;/a&gt;&lt;br /&gt;&amp;nbsp; &lt;a class="jive-link-external-small" href="http://www.element14.com/community/resources/statics/513455/cow.mp3?ICID=getstartedwpi-doc4" target="_blank"&gt;cow.mp3&lt;/a&gt;&lt;br /&gt;&amp;nbsp; and then connect the thumb drive to your Raspberry Pi.&lt;/p&gt;&lt;br /&gt;&lt;p style="margin:0;"&gt;Open file manager on your Pi, copy cow.mp3 to your Pi directory.&amp;nbsp; Then select pi-audio-button.py.txt and double-click to open it.&lt;/p&gt;&lt;br /&gt;&lt;p style="margin:0;"&gt;Select all the text and then toggle to the nano editor running in LXTerminal and right click to select Paste.&lt;/p&gt;&lt;br /&gt;&lt;p style="margin:0;"&gt;Once the text is in nano, press control-x (you&amp;#39;ll be prompted to save your work).&amp;nbsp; Press Y and then press enter to save it as the same name.&lt;/p&gt;&lt;div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="border:1px solid black;padding:6pt;border:solid windowtext 1pt;" valign="top"&gt;&lt;p style="margin:0;width:195px;"&gt;&lt;span style="background:silver;"&gt;chmod +x pi-audio-button.py&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style="border:1px solid black;padding:6pt;border-left:none;border:solid windowtext 1pt;" valign="top"&gt;&lt;span style="font-size:10.0pt;font-family:Helvetica;color:#3d3d3d;"&gt;Run this string&lt;/span&gt; to make the file executable – if you don’t do this step the program won’t run.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="border:1px solid black;padding:6pt;border:solid windowtext 1pt;" valign="top"&gt;&lt;p style="margin:0;width:195px;"&gt;&lt;span style="background:silver;"&gt;sudo python pi-audio-button.py&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style="border:1px solid black;padding:6pt;border-left:none;border:solid windowtext 1pt;" valign="top"&gt;&lt;p style="margin:0;"&gt;This command string will run the program.&lt;/p&gt;&lt;p style="margin:0;"&gt;When you see the text “When you’re ready, please press the button. . . “ press the button you installed on the breadboard.&amp;nbsp; The audio file should play.&amp;nbsp; And you’ve created your first pi project!&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;strong&gt;Remember&lt;/strong&gt; – everything in Linux is case sensitive so make sure you don’t inadvertently capitalize a word. Python is also quite particular about its indentation – that’s how it understands which commands work together – so be sure to set up the file exactly like it’s displayed.&amp;nbsp; &lt;a class="jive-link-external-small" href="http://www.element14.com/community/resources/statics/513455/pi-audio-button.py.txt?ICID=getstartedwpi-doc4-piaudiobtn" target="_blank"&gt;Download this as a text file: pi-audio-button.py.txt&lt;/a&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;table cellpadding="0" cellspacing="0" style="border:1px solid #000000;width:100%;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="border:1px solid #000000;padding:6pt 8pt;" valign="top"&gt;&lt;p style="margin:0;"&gt;import time, os&lt;br /&gt; try:&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;#Make sure we can import the GPIO library&lt;br /&gt;&lt;span style="padding-left:50px;"&gt;import RPi.GPIO as GPIO&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;except RuntimeError:&lt;/p&gt;&lt;p style="margin:0;padding-left:50px;"&gt;print (&amp;quot;Unable to import GPIO library.&amp;nbsp; Make sure that this is being run as root and that RPi.GPIO is properly installed!&amp;quot;)&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;#Pins will be referenced by the processor&amp;#39;s numbering scheme&lt;br /&gt;GPIO.setmode(GPIO.BCM)&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;#Tell the program you want to use pin number 22 as the input&lt;br /&gt;GPIO.setup(22, GPIO.IN)&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;#Set up a function to check the state of the GPIO pin&lt;br /&gt;def waitcheck():&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding-left:50px;"&gt;loop=1&lt;br /&gt;print (&amp;quot;When you&amp;#39;re ready, please press the button. . . &amp;quot;)&lt;br /&gt;while (loop):&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding-left:50px;"&gt;#Run as long as loop is nonzero and check the state of the button ten times per second&lt;/p&gt;&lt;p style="margin:0;padding-left:80px;"&gt;time.sleep(0.1)&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding-left:50px;"&gt;#If the button is pressed&lt;/p&gt;&lt;p style="margin:0;padding-left:80px;"&gt;if(GPIO.input(22)==0):&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding-left:80px;"&gt;#Cleanup GPIO since it is no longer needed&lt;/p&gt;&lt;p style="margin:0;padding-left:120px;"&gt;GPIO.cleanup()&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding-left:80px;"&gt;#Do not loop again&lt;/p&gt;&lt;p style="margin:0;padding-left:120px;"&gt;loop=0&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding-left:80px;"&gt;#Say the cow is coming&lt;/p&gt;&lt;p style="margin:0;padding-left:120px;"&gt;print (&amp;quot;Here comes the cow!&amp;quot;)&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding-left:80px;"&gt;#Actually play the sound&lt;/p&gt;&lt;p style="margin:0;padding-left:120px;"&gt;os.system(&amp;quot;omxplayer -o hdmi cow.mp3&amp;quot;)&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;try:&lt;/p&gt;&lt;p style="margin:0;padding-left:50px;"&gt;#call function, this will run forever&lt;br /&gt;waitcheck()&lt;br /&gt;#Exit this program if control-c is pressed&lt;/p&gt;&lt;p style="margin:0;"&gt;except KeyboardInterrupt:&lt;/p&gt;&lt;p style="margin:0;padding-left:50px;"&gt;#Restore GPIO to default state&lt;br /&gt;GPIO.cleanup()&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#007fac;font-size:12pt;"&gt;&lt;strong&gt;&lt;a name="partslist"&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: raspberry, your, pi, project, video, first, with, 4:, started, get, raspberry_pi_getting_started&lt;/div&gt;
</description></item></channel></rss>