<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Pi-Cars</title>
	<atom:link href="http://pi-cars.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://pi-cars.com</link>
	<description>Control your radio controlled car from your raspberry pi</description>
	<lastBuildDate>Sat, 18 May 2013 21:49:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='pi-cars.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/5d2bdd8adff8afb220955592d451442d?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Pi-Cars</title>
		<link>http://pi-cars.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://pi-cars.com/osd.xml" title="Pi-Cars" />
	<atom:link rel='hub' href='http://pi-cars.com/?pushpress=hub'/>
		<item>
		<title>Pi-Cars appears in Raspberry Pi For Dummies!</title>
		<link>http://pi-cars.com/2013/05/05/pi-cars-appears-in-raspberry-pi-for-dummies/</link>
		<comments>http://pi-cars.com/2013/05/05/pi-cars-appears-in-raspberry-pi-for-dummies/#comments</comments>
		<pubDate>Sun, 05 May 2013 16:04:56 +0000</pubDate>
		<dc:creator>Barnaby Kent</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[learning electronics]]></category>
		<category><![CDATA[learning programming]]></category>
		<category><![CDATA[pi-cars]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[raspberry pi]]></category>
		<category><![CDATA[raspberry pi for dummies]]></category>
		<category><![CDATA[scratch]]></category>
		<category><![CDATA[Tool Kit]]></category>

		<guid isPermaLink="false">http://pi-cars.com/?p=1172</guid>
		<description><![CDATA[Pi-Cars appears in the new book Raspberry Pi For Dummies by Sean McManus and Mike Cook, in a chapter at the end that outlines some inspiring Raspberry Pi projects. Co-author Sean McManus told us: “The book gets people up and &#8230; <a href="http://pi-cars.com/2013/05/05/pi-cars-appears-in-raspberry-pi-for-dummies/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=1172&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Pi-Cars appears in the new book Raspberry Pi For Dummies by Sean McManus and Mike Cook, in a chapter at the end that outlines some inspiring Raspberry Pi projects.<br />
Co-author Sean McManus told us: “The book gets people up and running with the Raspberry Pi and introduces them to programming in Scratch and Python, and to their first electronics projects interfaced with the Raspberry Pi. We wanted to give readers an idea of the kinds of things that others were building with the Raspberry Pi so we concluded the book with ten inspiring projects, including Pi-Cars.”</p>
<p>He added: “The videos for Pi-Cars clearly show how much fun the whole family have with them, and I liked the way that Scratch has been integrated. It’s a fantastically accessible way for everyone to get started with programming, including younger family members, and when you connect Scratch to real cars running around the house, it really brings the abstract world of programming to life!”</p>
<p>Other projects that were highlighted in the last chapter include a talking reporting system for a boat, automated Halloween lights, a jukebox and a weather station.</p>
<p>You can find out more about Raspberry Pi For Dummies and how to buy at Sean’s website &#8211; <a title="Pi-Cars on Raspberry Pi for Dummies" href="http://www.sean.co.uk/books/raspberry-pi-for-dummies/index.shtm" target="_blank">click here.</a></p>
<p>You can buy a Pi-Car or Took Kit at our Embark-ideas website &#8211; <a title="Embark Ideas website" href="https://www.embark-ideas.co.uk" target="_blank">click here.</a></p>
<div id="attachment_1173" class="wp-caption alignnone" style="width: 242px"><a href="http://barnabypaulkent.files.wordpress.com/2013/05/raspberry-pi-for-dummies-featuring-pi-cars.jpg"><img class="size-medium wp-image-1173" alt="Rasberry Pi for Dummies featuring pi-cars" src="http://barnabypaulkent.files.wordpress.com/2013/05/raspberry-pi-for-dummies-featuring-pi-cars.jpg?w=232&#038;h=300" width="232" height="300" /></a><p class="wp-caption-text">The Raspberry Pi for Dummies book written by Sean McManus and Mike Cook features Pi-Cars in the 10 projects to do with your Pi-Car.</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/barnabypaulkent.wordpress.com/1172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/barnabypaulkent.wordpress.com/1172/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=1172&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pi-cars.com/2013/05/05/pi-cars-appears-in-raspberry-pi-for-dummies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/bf149e636959abaa09b15d619258b985?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barnabypaulkent</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/05/raspberry-pi-for-dummies-featuring-pi-cars.jpg?w=232" medium="image">
			<media:title type="html">Rasberry Pi for Dummies featuring pi-cars</media:title>
		</media:content>
	</item>
		<item>
		<title>Pi-Cars python GPIO handler for Scratch configuration</title>
		<link>http://pi-cars.com/2013/04/28/pi-cars-python-gpio-handler-for-scratch-configuration/</link>
		<comments>http://pi-cars.com/2013/04/28/pi-cars-python-gpio-handler-for-scratch-configuration/#comments</comments>
		<pubDate>Sun, 28 Apr 2013 22:58:18 +0000</pubDate>
		<dc:creator>Barnaby Kent</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[GPIO handler]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[raspberry pi]]></category>
		<category><![CDATA[sd card]]></category>

		<guid isPermaLink="false">http://pi-cars.com/?p=1166</guid>
		<description><![CDATA[This details how to install and configure the Python Scratch handler for the Pi-Car and get it working with Scratch. You can download the software for doing this from the Pi-Store or buy one of our SD cards which is &#8230; <a href="http://pi-cars.com/2013/04/28/pi-cars-python-gpio-handler-for-scratch-configuration/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=1166&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This details how to install and configure the Python Scratch handler for the Pi-Car and get it working with Scratch. You can download the software <a title="Jump start – get your Pi-Car going with the Pi Store and Scratch" href="http://pi-cars.com/2013/01/03/jump-start-get-your-pi-car-going-with-the-pi-store/" target="_blank">for doing this from the Pi-Store</a> or <a title="https://www.embark-ideas.co.uk" href="https://www.embark-ideas.co.uk" target="_blank">buy one of our SD cards</a> which is easier but you can use the way detailed here if you prefer.</p>
<p>For the video lesson view the video below</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/91Vqftmybeo?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>If you can&#8217;t view video the full text-based lesson follows&#8230;</p>
<p>You should start from the <a title="Raspberry Pi welcome screen" href="http://pi-cars.com/2012/12/22/jump-start-get-your-pi-car-going-as-quick-as-you-can/screenshotmainpi/">screen with the big Raspberry Pi on it</a>. It is a good idea to start from fresh so pull the power lead out and put it back in again and wait for the prompt to appear. Type pi then raspberry for your password and startx to start the graphical screen.</p>
<p>Double click on the LX terminal:</p>
<div>
<dl id="attachment_387">
<dt><a href="http://pi-cars.com/2012/12/23/pi-cars-and-scratch-driving-lesson-1/pi-cars-terminal-on-raspberry-pi/" rel="attachment wp-att-387"><img title="LX Terminal window" alt="Terminal window" src="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-terminal-on-raspberry-pi.png?w=384&#038;h=289" width="384" height="289" /></a></dt>
<dd>Terminal window shown after double clicking on LX Terminal</dd>
</dl>
</div>
<p>Make sure you are in the right directory by typing:</p>
<pre class="brush: bash; title: ; notranslate">
cd /home/pi
</pre>
<p>You then need to open a text editor to copy in the information which will be the python program that will let Scratch talk with the GPIO pins to control your car. So type:</p>
<pre class="brush: bash; title: ; notranslate">
sudo nano picars.py
</pre>
<p>It is easiest if you use exactly the same wording I have used above here. This  should bring up a screen like this:</p>
<div>
<dl id="attachment_388">
<dt><a href="http://pi-cars.com/2012/12/23/pi-cars-and-scratch-driving-lesson-1/pi-cars-nano-on-terminal/" rel="attachment wp-att-388"><img alt="Nano" src="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-nano-on-terminal.png?w=640&#038;h=507" width="640" height="507" /></a></dt>
<dd>Nano on the LX Terminal on Raspberry Pi</dd>
</dl>
</div>
<p>You now need to copy in the text of the python program. Feel free to have a look at it but don&#8217;t think you have to understand it at the moment (you will be able to understand most of it by the end of your python driving lessons).</p>
<p>To get the program you need open the browser in your Raspberry Pi and go to this page on it (unless you are already viewing it on your Raspberry Pi!). You can open your browser by clicking on the icon as shown below:</p>
<div>
<dl id="attachment_389">
<dt><a href="http://pi-cars.com/2012/12/23/pi-cars-and-scratch-driving-lesson-1/pi-cars-highlight-browser-on-raspberry-pi/" rel="attachment wp-att-389"><img alt="Browser launch button" src="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-highlight-browser-on-raspberry-pi.png?w=640&#038;h=483" width="640" height="483" /></a></dt>
<dd>Where to click on the Raspberry Pi to launch the browser.</dd>
</dl>
</div>
<p>Visit this page on the browser by putting <a href="http://www.pi-cars.com" rel="nofollow">http://www.pi-cars.com</a> into the address bar and navigating to this page. You now need to copy the code in the box below, but there is a particular way to do this to ensure it is going to work and the instructions for this way are included beneath the code:</p>
<pre class="brush: python; title: ; notranslate">
#!/usr/bin/env python

&quot;&quot;&quot; Must be run as root - sudo python picars.py &quot;&quot;&quot;
&quot;&quot;&quot; Script based on original version from Simon Walters http://cymplecy.wordpress.com/ &quot;&quot;&quot;
&quot;&quot;&quot; Modified slightly when troubleshooting. Currenly only does GPIO outputs in order to simplify &quot;&quot;&quot;

import time, RPi.GPIO as GPIO
import socket
import sys
import threading
import time
import sys
import struct
from array import *
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.OUT)
GPIO.setup(11,GPIO.OUT)
GPIO.setup(12,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)
GPIO.output(7,0)
GPIO.output(11,0)
GPIO.output(12,0)
GPIO.output(13,0)
GPIO.output(15,0)

PORT = 42001
DEFAULT_HOST = '127.0.0.1'
#HOST = askstring('Scratch Connector', 'IP:')
BUFFER_SIZE = 240 #used to be 100
SOCKET_TIMEOUT = 1

SCRATCH_SENSOR_NAME_OUTPUT = (
'gpio-output0',
'gpio-output1',
'gpio-output2',
'gpio-output3',
'gpio-output4'
)

#Map gpio to real connector P1 Pins
GPIO_PINS = array('i',[7,11,12,13,15])
GPIO_PIN_OUTPUT = array('i')
GPIO_PIN_INPUT = array('i')
print &quot;Output Pins are:&quot;
for i in range(0,len(SCRATCH_SENSOR_NAME_OUTPUT)):
	print GPIO_PINS[i]
	GPIO_PIN_OUTPUT.append(GPIO_PINS[i])

def create_socket(host, port):
    while True:
        try:
            print 'Trying'
            scratch_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            scratch_sock.connect((host, port))
            break
        except socket.error:
            print &quot;There was an error connecting to Scratch! It may not have been started yet&quot;
            print &quot;I am looking for Scratch at host: %s, port: %s&quot; % (host, port)
            time.sleep(3)
            #sys.exit(1)

    return scratch_sock

def cleanup_threads(thread):
	print 'About to stop thread'
	thread.stop()
	GPIO.cleanup()
	print 'Finished cleanup'
#	for thread in threads:
#		thread.stop()
#		for thread in threads:
#			thread.join()

class ScratchListener(threading.Thread):
    def __init__(self, socket):
        threading.Thread.__init__(self)
        self.scratch_socket = socket
        self._stop = threading.Event()

    def stop(self):
        self._stop.set()

    def stopped(self):
        return self._stop.isSet()

    def physical_pin_update(self, pin_index, value):
        physical_pin = GPIO_PIN_OUTPUT[pin_index]
        print 'setting GPIO %d (physical pin %d) to %d' % (pin_index,physical_pin,value)
        GPIO.output(physical_pin, value)

    def run(self):
	    while not self.stopped():
		    try:
			    data = self.scratch_socket.recv(BUFFER_SIZE)
			    dataraw = data[4:].lower()
			    print 'Length: %d, Data: %s' % (len(dataraw), dataraw)
			    print 'received something: %s' % dataraw
#			    time.sleep(0.2)
		    except socket.timeout:
			    print 'Socket timeout'
			    continue
		    except:
			    break
		    if 'sensor-update' in dataraw:
			    print 'Sensor update detected'
			    #check for individual port commands
			    for i in range(len(SCRATCH_SENSOR_NAME_OUTPUT)):
				     if 'gpio-output'+str(i) in dataraw:
					     print 'Found '+ 'gpio-output'+str(i)
					     outputall_pos = dataraw.find('gpio-output'+str(i))
					     sensor_value = dataraw[(outputall_pos+14):].split()
					     #print sensor_value[0]
					     self.physical_pin_update(i,int(sensor_value[0]))

if __name__ == '__main__':
    if len(sys.argv) &gt; 1:
        host = sys.argv[1]
    else:
        host = DEFAULT_HOST

    # open the socket
    print 'Connecting...' ,
    the_socket = create_socket(host, PORT)
    print 'Connected!'

    the_socket.settimeout(SOCKET_TIMEOUT)
    listener = ScratchListener(the_socket)
    listener.start()
    print 'Starting cleaner'
    try:
	    while True:
		    time.sleep(0.5)
    except KeyboardInterrupt:
	    cleanup_threads(listener)
	    sys.exit()

</pre>
<p>To copy the code above click on the open code in new window icon &#8211; highlighted with a red circle in the diagram below:</p>
<div>
<dl id="attachment_398">
<dt><a href="http://pi-cars.com/2012/12/23/pi-cars-and-scratch-driving-lesson-1/pi-cars-copying-code-text-from-the-browser-on-raspberry-pi/" rel="attachment wp-att-398"><img alt="Show code icon" src="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-copying-code-text-from-the-browser-on-raspberry-pi.png?w=640&#038;h=344" width="640" height="344" /></a></dt>
<dd>How to copy code from the browser &#8211; click on the show code icon.</dd>
</dl>
</div>
<p>This will open up a separate window with just the code in it:</p>
<div>
<dl id="attachment_399">
<dt><a href="http://pi-cars.com/2012/12/23/pi-cars-and-scratch-driving-lesson-1/pi-cars-copying-code-text-from-the-code-window-in-the-browser-on-raspberry-pi/" rel="attachment wp-att-399"><img alt="Code window" src="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-copying-code-text-from-the-code-window-in-the-browser-on-raspberry-pi.png?w=592&#038;h=562" width="592" height="562" /></a></dt>
<dd>Code window with the code to copy. It should be done from here to preserve the formatting.</dd>
</dl>
</div>
<p>In this window you can then press CTRL followed by the A button at the same time which will select all of the code in the window. You will then need to press the CTRL button followed by the C button to copy it to the clip board.</p>
<p>You now need to choose the terminal window you opened earlier and copy the python code into it. To do that you can right click in the terminal window and choose paste:</p>
<div>
<dl id="attachment_400">
<dt><a href="http://pi-cars.com/2012/12/23/pi-cars-and-scratch-driving-lesson-1/pi-cars-pasting-into-nano-on-raspberry-pi/" rel="attachment wp-att-400"><img alt="Paste into Nano" src="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-pasting-into-nano-on-raspberry-pi.png?w=628&#038;h=498" width="628" height="498" /></a></dt>
<dd>Paste the code into the text editor (nano) by using CTRL V</dd>
</dl>
</div>
<p>To save the file you can just press the CTRL key followed by the X key at the same time. This will ask you if you want to save the file and make sure you choose Y.</p>
<p>Finally you need to type:</p>
<pre class="brush: bash; title: ; notranslate">
sudo python picars.py
</pre>
<p>This should give you an output like the below:</p>
<div>
<dl id="attachment_402">
<dt><a href="http://pi-cars.com/2012/12/23/pi-cars-and-scratch-driving-lesson-1/pi-cars-starting-up-pi-cars-script/" rel="attachment wp-att-402"><img alt="picars script startup" src="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-starting-up-pi-cars-script.png?w=530&#038;h=316" width="530" height="316" /></a></dt>
<dd>The picars script starting up and waiting for Scratch to connect.</dd>
</dl>
</div>
<p>This shows you that it is waiting for Scratch to tell it something which is what we want &#8211; Scratch is not started yet so it should be waiting. You will need to keep that terminal window so don&#8217;t shut it by clicking on the X but you can minimise it.</p>
<p>So with that palava over (it should be much easier when we get the apt-get repository up and running) you are now ready to fire up Scratch and talk to the Pi-Car through it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/barnabypaulkent.wordpress.com/1166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/barnabypaulkent.wordpress.com/1166/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=1166&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pi-cars.com/2013/04/28/pi-cars-python-gpio-handler-for-scratch-configuration/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/bf149e636959abaa09b15d619258b985?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barnabypaulkent</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-terminal-on-raspberry-pi.png" medium="image">
			<media:title type="html">LX Terminal window</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-nano-on-terminal.png" medium="image">
			<media:title type="html">Nano</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-highlight-browser-on-raspberry-pi.png" medium="image">
			<media:title type="html">Browser launch button</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-copying-code-text-from-the-browser-on-raspberry-pi.png" medium="image">
			<media:title type="html">Show code icon</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-copying-code-text-from-the-code-window-in-the-browser-on-raspberry-pi.png" medium="image">
			<media:title type="html">Code window</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-pasting-into-nano-on-raspberry-pi.png" medium="image">
			<media:title type="html">Paste into Nano</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2012/12/pi-cars-starting-up-pi-cars-script.png" medium="image">
			<media:title type="html">picars script startup</media:title>
		</media:content>
	</item>
		<item>
		<title>Pi-Cars Showroom</title>
		<link>http://pi-cars.com/2013/04/10/pi-cars-showroom/</link>
		<comments>http://pi-cars.com/2013/04/10/pi-cars-showroom/#comments</comments>
		<pubDate>Tue, 09 Apr 2013 23:06:08 +0000</pubDate>
		<dc:creator>Barnaby Kent</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hobby fun]]></category>
		<category><![CDATA[new bright]]></category>
		<category><![CDATA[pi-cars]]></category>
		<category><![CDATA[radio controlled cars]]></category>
		<category><![CDATA[showroom]]></category>

		<guid isPermaLink="false">http://pi-cars.com/?p=1103</guid>
		<description><![CDATA[Welcome to the Pi-Cars showroom. We plan to showcase any radio controlled cars in here that have been converted to Pi-Cars and also some of the things they get up to. If you have created a Pi-Car with our Tool &#8230; <a href="http://pi-cars.com/2013/04/10/pi-cars-showroom/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=1103&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Welcome to the Pi-Cars showroom. We plan to showcase any radio controlled cars in here that have been converted to Pi-Cars and also some of the things they get up to. If you have created a Pi-Car with our <a title="Reserve Pi-Car Tool Kit" href="http://pi-cars.com/order-pi-car-tool-kit/">Tool Kit</a> or worked it out on your own get in touch through our <a title="About" href="http://pi-cars.com/about-2/">contact page</a> and we will feature it here.</p>
<p>Lots of different RC cars will work with the Tool Kit &#8211; basically anything that uses the TX2B chip. Listed below are the ones that can be bought together with the Tool Kit together with other models that we have had working in the past.</p>
<h3><strong>Cars that were used when creating the Tool Kit and can <a title="Reserve Pi-Car Tool Kit" href="http://pi-cars.com/order-pi-car-tool-kit/" target="_blank">be bought</a> together with the Tool Kit:</strong></h3>
<ul>
<li><a title="New Bright Ferrari" href="http://www.newbright.com/product/view/id/220" target="_blank"><strong style="line-height:1.5;">New Bright Ferrari 1:24 Model</strong></a></li>
</ul>
<div id="attachment_1105" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-sport-ferrari-458-italia-1_24-radio-controlled-car.png"><img class="size-medium wp-image-1105" alt="New Bright Sport Ferrari 458 Italia 1_24 Radio Controlled Car" src="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-sport-ferrari-458-italia-1_24-radio-controlled-car.png?w=300&#038;h=211" width="300" height="211" /></a><p class="wp-caption-text">New Bright 1:24 Ferrari available in the Pi-Car Tool Kit</p></div>
<p>Can be bought separately <a title="New Bright Ferrari" href="http://www.tesco.com/direct/new-bright-sport-ferrari-458-italia-124-radio-controlled-car/211-3907.prd?pageLevel=&amp;skuId=211-3907" target="_blank">from here.</a></p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/F1nWjRTs5I0?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<ul>
<li><strong><span style="line-height:16px;">New Bright RC Toy Pick Up Model</span></strong></li>
</ul>
<div id="attachment_1107" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-rc-toy-pick-up.png"><img class="size-medium wp-image-1107" alt="New Bright RC Toy Pick Up" src="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-rc-toy-pick-up.png?w=300&#038;h=184" width="300" height="184" /></a><p class="wp-caption-text">New Bright Toy Pick Up truck that can be bought with the Pi-Cars Tool Kit</p></div>
<p>Can be bought separately <a title="New Bright Toy Pickup " href="http://www.tesco.com/direct/new-bright-rc-toy-pick-up-truck/215-2137.prd?pageLevel=&amp;skuId=215-2137" target="_blank">from here.</a></p>
<p><strong>Other New Bright Cars we know work with the Pi-Cars Tool Kit:</strong></p>
<ul>
<li><a title="New Bright RAM RC Basics 1:24" href="http://www.newbright.com/product/view/id/47" target="_blank"><strong><span style="line-height:16px;">New Bright RAM Basics 1:24 Scale</span></strong></a></li>
</ul>
<div id="attachment_1108" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-ram-basics-1_24-scale.png"><img class="size-medium wp-image-1108" alt="New Bright RAM Basics 1_24 Scale" src="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-ram-basics-1_24-scale.png?w=300&#038;h=209" width="300" height="209" /></a><p class="wp-caption-text">New Bright RAM Basics 1_24 Scale</p></div>
<div id="attachment_1109" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-ram-basics-black-1_24-scale.png"><img class="size-medium wp-image-1109" alt="New Bright RAM Basics Black 1_24 Scale" src="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-ram-basics-black-1_24-scale.png?w=300&#038;h=204" width="300" height="204" /></a><p class="wp-caption-text">Also works with Pi-Cars Tool Kit New Bright RAM Basics Black 1_24 Scale</p></div>
<ul>
<li><a title="New Bright HEMI Mud Slinger" href="http://www.newbright.com/product/view/id/138" target="_blank"><strong><span style="line-height:16px;">New Bright Ram HEMI, Mud Slingers, 1:6 Scale</span></strong></a></li>
</ul>
<div id="attachment_1110" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-ram-hemi-mud-slingers-1_6-scale.png"><img class="size-medium wp-image-1110" alt="New Bright Ram HEMI, Mud Slingers, 1_6 Scale" src="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-ram-hemi-mud-slingers-1_6-scale.png?w=300&#038;h=199" width="300" height="199" /></a><p class="wp-caption-text">Works with Pi-Cars Tool Kit &#8211; New Bright Ram HEMI, Mud Slingers, 1_6 Scale</p></div>
<ul>
<li><strong>New Bright Sport Audi 1:16 Scale</strong></li>
</ul>
<div id="attachment_1111" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-rc-sport-audi.png"><img class="size-medium wp-image-1111" alt="New Bright RC Sport Audi" src="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-rc-sport-audi.png?w=300&#038;h=190" width="300" height="190" /></a><p class="wp-caption-text">New Bright RC Sport Audi for connecting to Pi-Car</p></div>
<p>We believe any of the New Bright Models will work with the same Tool Kit and instructions that we have provided in the <a title="Pi-Cars Factory – Tool Kit" href="http://pi-cars.com/2013/01/24/pi-cars-factory-beginners-tool-kit/" target="_blank">Pi-Cars factory</a> as we understand they use the same chip &#8211; if you have one already then why not convert it with the Tool Kit and <a title="About" href="http://pi-cars.com/about-2/" target="_blank">let us know.</a></p>
<p><strong>Hobby Fun Cars we converted:</strong></p>
<p>We also converted a number of Hobby Fun cars from China. We don&#8217;t think they are available for sale in the UK but had fun with them and were impressed by them to. We gave these away in our <a title="Free Pi-Cars!" href="http://pi-cars.com/free-pi-cars/" target="_blank">earlier competition.</a></p>
<ul>
<li><a title="Hobby Fun Construction Car" href="http://www.hobby-fun.com/RC-Other-Car-605.html" target="_blank"><strong><span style="line-height:16px;">4 Channel Construction Car</span></strong></a></li>
</ul>
<div id="attachment_1112" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/hobby-fun-radio-control-construction-vehicle.png"><img class="size-medium wp-image-1112" alt="Hobby Fun Radio Control Construction Vehicle" src="http://barnabypaulkent.files.wordpress.com/2013/04/hobby-fun-radio-control-construction-vehicle.png?w=300&#038;h=194" width="300" height="194" /></a><p class="wp-caption-text">Hobby Fun Radio Control Construction Vehicle that has been converted to a Pi-Car.</p></div>
<ul>
<li><span style="line-height:16px;"><a title="Hobby Fun Mercedes car" href="http://www.hobby-fun.com/Licensed-car-530.html" target="_blank"><strong>1:18 Mercedes-Benz SL65 AMG</strong></a><br />
</span></li>
</ul>
<div id="attachment_1113" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/1_18-mercedes-benz-sl65-amg.png"><img class="size-medium wp-image-1113" alt="1_18 Mercedes-Benz SL65 AMG" src="http://barnabypaulkent.files.wordpress.com/2013/04/1_18-mercedes-benz-sl65-amg.png?w=300&#038;h=200" width="300" height="200" /></a><p class="wp-caption-text">1_18 Mercedes-Benz SL65 AMG that we have converted to a Pi-Car.</p></div>
<p><strong>Pi-Cars converted by other people</strong></p>
<ul>
<li><strong>Porsche 911 GT3 RS Radio Controlled Car<a title="Hobby Fun Mercedes car" href="http://www.hobby-fun.com/Licensed-car-530.html" target="_blank"><br />
</a></strong></li>
</ul>
<div id="attachment_1195" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/argos-porsche.png"><img class="size-medium wp-image-1195" alt="Porsche 911 from Argos" src="http://barnabypaulkent.files.wordpress.com/2013/04/argos-porsche.png?w=300&#038;h=258" width="300" height="258" /></a><p class="wp-caption-text">Porsche 911 from Argos converted by Nilesh Gajjar</p></div>
<p>Well done to Nilesh Gajjar for converting this one. It can be bought from Argos &#8211; <a title="Porsche car" href="http://www.argos.co.uk/static/Product/partNumber/3882562.htm">click here.</a> Here is how he wired up the controller with one of our Pi-Car Tool Kits:</p>
<div id="attachment_1196" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/nilishporsch.jpg"><img class="size-medium wp-image-1196" alt="Porsche inside controller " src="http://barnabypaulkent.files.wordpress.com/2013/04/nilishporsch.jpg?w=300&#038;h=225" width="300" height="225" /></a><p class="wp-caption-text">Converted Porsch radio controlled car to Pi-Car</p></div>
<div id="attachment_1197" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/porsche-controller-connected-test-points.jpg"><img class="size-medium wp-image-1197" alt="Porsche Controller connected test points" src="http://barnabypaulkent.files.wordpress.com/2013/04/porsche-controller-connected-test-points.jpg?w=300&#038;h=225" width="300" height="225" /></a><p class="wp-caption-text">Inside of the Porsche controller connected up as a Pi-Car.</p></div>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/barnabypaulkent.wordpress.com/1103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/barnabypaulkent.wordpress.com/1103/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=1103&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pi-cars.com/2013/04/10/pi-cars-showroom/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/bf149e636959abaa09b15d619258b985?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barnabypaulkent</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-sport-ferrari-458-italia-1_24-radio-controlled-car.png?w=300" medium="image">
			<media:title type="html">New Bright Sport Ferrari 458 Italia 1_24 Radio Controlled Car</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-rc-toy-pick-up.png?w=300" medium="image">
			<media:title type="html">New Bright RC Toy Pick Up</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-ram-basics-1_24-scale.png?w=300" medium="image">
			<media:title type="html">New Bright RAM Basics 1_24 Scale</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-ram-basics-black-1_24-scale.png?w=300" medium="image">
			<media:title type="html">New Bright RAM Basics Black 1_24 Scale</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-ram-hemi-mud-slingers-1_6-scale.png?w=300" medium="image">
			<media:title type="html">New Bright Ram HEMI, Mud Slingers, 1_6 Scale</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/new-bright-rc-sport-audi.png?w=300" medium="image">
			<media:title type="html">New Bright RC Sport Audi</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/hobby-fun-radio-control-construction-vehicle.png?w=300" medium="image">
			<media:title type="html">Hobby Fun Radio Control Construction Vehicle</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/1_18-mercedes-benz-sl65-amg.png?w=300" medium="image">
			<media:title type="html">1_18 Mercedes-Benz SL65 AMG</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/argos-porsche.png?w=300" medium="image">
			<media:title type="html">Porsche 911 from Argos</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/nilishporsch.jpg?w=300" medium="image">
			<media:title type="html">Porsche inside controller </media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/porsche-controller-connected-test-points.jpg?w=300" medium="image">
			<media:title type="html">Porsche Controller connected test points</media:title>
		</media:content>
	</item>
		<item>
		<title>Setting up a wireless connection on the Raspberry Pi</title>
		<link>http://pi-cars.com/2013/04/08/setting-up-a-wireless-connection-on-the-raspberry-pi/</link>
		<comments>http://pi-cars.com/2013/04/08/setting-up-a-wireless-connection-on-the-raspberry-pi/#comments</comments>
		<pubDate>Sun, 07 Apr 2013 23:31:40 +0000</pubDate>
		<dc:creator>Barnaby Kent</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[raspberry pi]]></category>
		<category><![CDATA[remote access]]></category>
		<category><![CDATA[startx]]></category>
		<category><![CDATA[vncviewer]]></category>
		<category><![CDATA[wireless setup]]></category>

		<guid isPermaLink="false">http://pi-cars.com/?p=1086</guid>
		<description><![CDATA[To setup the wireless connection on the Raspberry Pi you will need to: Buy a USB wireless adapter such as this one Plug it into the USB slot on your Raspberry Pi Configure it to join a wireless network To &#8230; <a href="http://pi-cars.com/2013/04/08/setting-up-a-wireless-connection-on-the-raspberry-pi/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=1086&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>To setup the wireless connection on the Raspberry Pi you will need to:</p>
<ul>
<li><span style="line-height:16px;">Buy a USB wireless adapter <a title="USB wireless adapter" href="http://www.amazon.co.uk/USB-Wifi-Adapter-Raspberry-Pi/dp/B009FA2UYK/ref=sr_1_2?ie=UTF8&amp;qid=1365376731&amp;sr=8-2&amp;keywords=raspberry+Pi+wireless+USB+adapter" target="_blank">such as this one</a></span></li>
<li>Plug it into the USB slot on your Raspberry Pi</li>
<li>Configure it to join a wireless network</li>
</ul>
<p>To configure the Raspberry Pi to connect to a wireless network perform the following steps:</p>
<p>Login to your Raspberry Pi either with a keyboard and mouse connected by pressing &#8216;startx&#8217; at the prompt, or connect remotely using VNC viewer as <a title="Set up remote access to your Raspberry Pi" href="http://pi-cars.com/2012/12/20/set-up-remote-access-to-your-raspberry-pi/" target="_blank">shown in this post.</a></p>
<p>The first thing to do is double click on the wireless config item on the start screen:</p>
<div id="attachment_537" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2012/12/wirelessconfig.png"><img class="size-medium wp-image-537" alt="Raspberry Pi Wireless config" src="http://barnabypaulkent.files.wordpress.com/2012/12/wirelessconfig.png?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Double click on the wireless configuration icon in order to add password details for your wireless network.</p></div>
<div>
<dl>
<dt></dt>
</dl>
<p> This will bring up the following prompt:</p>
<div id="attachment_1088" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/click-on-wireless-config-icon.png"><img class="size-medium wp-image-1088" alt="Click on Wireless Config Icon" src="http://barnabypaulkent.files.wordpress.com/2013/04/click-on-wireless-config-icon.png?w=300&#038;h=297" width="300" height="297" /></a><p class="wp-caption-text">Clicking on wireless config on the Raspberry Pi desktop brings up this page.</p></div>
</div>
<p>You then need to click on the Scan button:</p>
<div id="attachment_1087" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/click-on-scan-to-show-following-screen.png"><img class="size-medium wp-image-1087" alt="Click on Scan to show following screen" src="http://barnabypaulkent.files.wordpress.com/2013/04/click-on-scan-to-show-following-screen.png?w=300&#038;h=243" width="300" height="243" /></a><p class="wp-caption-text">On the desktop click on Scan to show the available networks.</p></div>
<p>Double click on the network you want to connect to which should bring up the following screen:</p>
<div id="attachment_1089" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/double-click-on-the-wireless-network-to-show-the-this-screen.png"><img class="size-medium wp-image-1089" alt="Double click on the wireless network to show the this screen" src="http://barnabypaulkent.files.wordpress.com/2013/04/double-click-on-the-wireless-network-to-show-the-this-screen.png?w=300&#038;h=233" width="300" height="233" /></a><p class="wp-caption-text">Once you have double clicked on the wireless network you want to join this screen should show.</p></div>
<p>You can then enter your password into the PSK field and click Add. Note that you may need to change the encryption method to the one that your wireless network uses:</p>
<div id="attachment_1090" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/enter-your-password-into-the-psk-field.png"><img class="size-medium wp-image-1090" alt="Enter your password into the PSK field" src="http://barnabypaulkent.files.wordpress.com/2013/04/enter-your-password-into-the-psk-field.png?w=300&#038;h=244" width="300" height="244" /></a><p class="wp-caption-text">Your password can be entered in the PSK field.</p></div>
<p>From a terminal you should now be able to ping google:</p>
<div id="attachment_1093" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/you-should-now-be-able-to-ping-google.png"><img class="size-medium wp-image-1093" alt="Enter your password into the PSK field" src="http://barnabypaulkent.files.wordpress.com/2013/04/you-should-now-be-able-to-ping-google.png?w=300&#038;h=226" width="300" height="226" /></a><p class="wp-caption-text">Checking you can ping google with the wireless network setup.</p></div>
<p>You can also inspect the network connection by typing the following into a terminal:</p>
<pre class="brush: bash; title: ; notranslate">
sudo /sbin/ifconfig
</pre>
<p>This should give you a screen similar to the following:</p>
<div id="attachment_1092" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/04/ifconfig-ouput-showing-network-setup.png"><img class="size-medium wp-image-1092" alt="ifconfig ouput showing network setup" src="http://barnabypaulkent.files.wordpress.com/2013/04/ifconfig-ouput-showing-network-setup.png?w=300&#038;h=190" width="300" height="190" /></a><p class="wp-caption-text">Output screen showing the setup on your interfaces.</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/barnabypaulkent.wordpress.com/1086/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/barnabypaulkent.wordpress.com/1086/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=1086&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pi-cars.com/2013/04/08/setting-up-a-wireless-connection-on-the-raspberry-pi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/bf149e636959abaa09b15d619258b985?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barnabypaulkent</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2012/12/wirelessconfig.png?w=300" medium="image">
			<media:title type="html">Raspberry Pi Wireless config</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/click-on-wireless-config-icon.png?w=300" medium="image">
			<media:title type="html">Click on Wireless Config Icon</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/click-on-scan-to-show-following-screen.png?w=300" medium="image">
			<media:title type="html">Click on Scan to show following screen</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/double-click-on-the-wireless-network-to-show-the-this-screen.png?w=300" medium="image">
			<media:title type="html">Double click on the wireless network to show the this screen</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/enter-your-password-into-the-psk-field.png?w=300" medium="image">
			<media:title type="html">Enter your password into the PSK field</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/you-should-now-be-able-to-ping-google.png?w=300" medium="image">
			<media:title type="html">Enter your password into the PSK field</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/04/ifconfig-ouput-showing-network-setup.png?w=300" medium="image">
			<media:title type="html">ifconfig ouput showing network setup</media:title>
		</media:content>
	</item>
		<item>
		<title>Python while loops &#8211; Driving lesson #5</title>
		<link>http://pi-cars.com/2013/03/04/python-while-loops-driving-lesson-5/</link>
		<comments>http://pi-cars.com/2013/03/04/python-while-loops-driving-lesson-5/#comments</comments>
		<pubDate>Mon, 04 Mar 2013 21:21:37 +0000</pubDate>
		<dc:creator>Barnaby Kent</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Under the bonnet]]></category>
		<category><![CDATA[pi-cars]]></category>
		<category><![CDATA[python driving lesson]]></category>
		<category><![CDATA[python driving lesson 5]]></category>
		<category><![CDATA[under the bonnet]]></category>
		<category><![CDATA[while loops]]></category>

		<guid isPermaLink="false">http://pi-cars.com/?p=962</guid>
		<description><![CDATA[Pre-driving checks If you are here you should be able use an editor to write Python code to control  your Pi-Car and understand what we mean when we talk about constants, variables and print statements. If not by all means &#8230; <a href="http://pi-cars.com/2013/03/04/python-while-loops-driving-lesson-5/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=962&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<ul>
<li><strong><span style="color:#444444;">Pre-driving checks</span></strong></li>
</ul>
<p>If you are here you should be able use an editor to write Python code to control  your Pi-Car and understand what we mean when we talk about constants, variables and print statements. If not by all means have a go at this lesson but if you get stuck try <a title="Pi-Cars and Python – Driving Lesson #1" href="http://pi-cars.com/2013/01/10/pi-cars-and-python-driving-lesson-1/">Driving Lesson#1</a>, <a title="Introduction to Python, constants and print statements – Driving Lesson #2" href="http://pi-cars.com/2013/02/15/introduction-to-programming/">Driving Lesson#2</a>, <a title="Variables and commenting – Driving Lesson #3" href="http://pi-cars.com/2013/03/01/variables-and-while-loops-driving-lesson-3/">Driving Lesson#3</a> or <a title="Python if else statements – Driving Lesson #4" href="http://pi-cars.com/2013/03/03/python-if-statements-driving-lesson-4/">Driving Lesson#4</a>.</p>
<ul>
<li><strong><span style="color:#444444;">What&#8217;s in this driving lesson?</span></strong></li>
</ul>
<p>In this lesson we will look at another type of logical instruction and how we can use it to affect the &#8216;flow&#8217; of the program. The instruction we will look at is called a &#8216;while loop&#8217;. This will help greatly in helping us to make the Raspberry Pi repeat instructions rather than have to continually write them out.</p>
<p>As with the other lessons you may get to the end and not realise how powerful the instruction is but try and think of examples in bigger programs how it could be used.</p>
<ul>
<li><strong><span style="color:#444444;">A little theory</span></strong></li>
</ul>
<p>Unless you already know what a while instruction is you probably do need to read the theory section as it takes a little bit of time to get used to it. However, you can of course jump into the driving part and then come back to review this if necessary.</p>
<p><em><strong>while instructions (also known as &#8216;while loops&#8217;)</strong></em><br />
In the real world we sometimes need to repeat the same task over and over again a number times until it&#8217;s finished.</p>
<p>An example of this is a race where we have to drive around a track a fixed number of times to complete it. Sometimes we will count down the number of laps completed i.e count down from 10 taking 1 off each time (10,9,8 etc) until we get to 0 and are finished.</p>
<p>Other times we will count up (1, 2, 3 etc) once each lap is finished, until we reach the number of laps to complete the race. We may also say we are on the third lap once we start it but do not count it until that lap is completed.</p>
<p>We may also want to do things whilst a certain situation is true e.g switch on windscreen wipers which will then continue to wipe whilst they are turned on, (or if you have sensors until  they go of automatically as there&#8217;s no longer any rain). Another example is when we start a car, the engine will continually run whilst the key is turned in the ignition.</p>
<p>In a program we also want to be able to do this sort of thing. The above examples are perfect examples of while loops in a program. What a while loop lets us do is tell the Raspberry Pi to repeat a certain block of instructions either a certain number of times or whilst a certain thing is true &#8211; such as the value of a variable currently being a certain value.</p>
<ul>
<li><span style="line-height:16px;"><strong>Lets get driving&#8230;</strong><br />
</span></li>
</ul>
<p><span style="line-height:1.5;">The first thing we have to do before we start racing is to start the engine. Once you have done that you can then race the car around the track. So how can we do this in a python program?</span></p>
<p>A while loop lets us tell the Raspberry Pi to keep on repeating an instruction or set of instructions. It will go through the block of instructions in order and then start at the beginning of the block again.</p>
<p>We can also tell the Raspberry Pi to only repeat the instructions if a certain thing is true, <a title="Python if else statements – Driving Lesson #4" href="http://pi-cars.com/2013/03/03/python-if-statements-driving-lesson-4/">a bit like we did in the if statement</a> in the last lesson. The way we write this in the Python file is as follows:</p>
<pre class="brush: python; title: ; notranslate">
engineStarted = &quot;on&quot;

while engineStarted == &quot;on&quot;:
  print &quot;Pi-Car engine running&quot;
  time.sleep(2)

</pre>
<p>You can see above that we write the word &#8216;while&#8217; followed by something that we want to check. If it is correct &#8211; this is also called being &#8216;true&#8217; &#8211; the indented instructions below it will be repeated again and again. As with the if statement you can make the instructions indented by just pressing the tab key at the start of the line.</p>
<p>In the example above the variable engineStarted is being checked as to whether it is equal to on. Remember that the == symbol means &#8216;equal to&#8217; and note how it is two equal signs rather than one. If engineStarted is equal to &#8216;on&#8217; then the Raspberry Pi will execute the instructions below it &#8211; meaning it will print out some text and then wait for 2 seconds. Also notice that you need to put a colon &#8216;:&#8217; symbol after the check &#8211; you have to do this, it is what the Python language accepts to make the Raspberry Pi process the instruction correctly.</p>
<p>If you run this program you will see it continually printing out &#8220;Pi-Car engine running&#8221; with a 3 second wait. The Raspberry Pi will continue to do this again and again and again. This is because in the code we wrote engineStarted will always be equal to &#8220;on&#8221; as this is what we set it to at the top of the file and we don&#8217;t change it anywhere else.</p>
<p>This does give us a bit of a problem in that we want to do something else rather than just watch the Raspberry Pi print out a statement forever. To stop the program and the while loop running you can press CTR + D or CTR + C.</p>
<p>So now we understand the while loop lets make it do something useful. We want it to make the Pi-Car do a certain number of laps before stopping. To do this we can combine the while statement with the <a title="Python if else statements – Driving Lesson #4" href="http://pi-cars.com/2013/03/03/python-if-statements-driving-lesson-4/">if statement that we learnt in the last lesson.</a></p>
<pre class="brush: python; title: ; notranslate">
engineStarted = &quot;on&quot;
lapsCompleted = 0

while engineStarted == &quot;on&quot;:
       GPIO.output(FORWARDS, ON)
       GPIO.output(RIGHT, ON)
       print(&quot;Engine running, Pi-Car should be driving in a circle&quot;)
       if (lapsCompleted &lt; 10) :
              print(&quot;Staring a new lap, laps completed&quot;,lapsCompleted)
              time.sleep(3)
              lapsCompleted = lapsCompleted + 1
       else :
              print(&quot;Laps done = &quot;,lapsCompleted,&quot; race finished lets turn off the Pi-Car&quot;)
              GPIO.output(FORWARDS,OFF)
              GPIO.output(RIGHT,OFF)
              GPIO.cleanup()
              engineStarted = &quot;off&quot;
</pre>
<p>The main thing to discuss here is how we have added the if statement in the indented code after the while statement. This means that every time the Raspberry Pi goes through all of the code in the while loop it will evaluate the line</p>
<pre class="brush: python; title: ; notranslate">
if (lapsCompleted &lt; 10) :
</pre>
<p><span style="line-height:1.5;">We have already defined the lapsCompleted variable earlier in the program to a value of 0. We want to check on each loop that the value of lapsCompleted is not over a certain amount &#8211; we have chosen 10 here. In the last lesson we used the &gt; symbol which means &#8216;more than&#8217;. Here we are using the opposite which means &#8216;less than&#8217;.</span></p>
<p><span style="line-height:1.5;">To make this while loop work we also have to increase  the lapsCompleted each time by one, if we didn&#8217;t it would mean that the loop would go on forever as before. This is referred to in programming as an infinite loop and can happen </span>surprisingly<span style="line-height:1.5;"> often and easily. </span></p>
<p><span style="line-height:1.5;">The way we increase the number of laps completed is as follows:</span></p>
<pre class="brush: python; title: ; notranslate">
lapsCompleted = lapsCompleted + 1
</pre>
<p>Notice that even though the code we have looked at so far does check for the number of laps completed, it does not actually do anything to stop the while loop. This is done in the else section:</p>
<pre class="brush: python; title: ; notranslate">
else :
              print(&quot;Laps done = &quot;,lapsCompleted,&quot; race finished lets turn off the Pi-Car&quot;)
              GPIO.output(FORWARDS,OFF)
              GPIO.output(RIGHT,OFF)
              GPIO.cleanup()
              engineStarted = &quot;off&quot;
</pre>
<p>You can see us here turning off the GPIO pins and also setting the enigneStarted variable to another value. This means that when the while loop next runs and checks whether engineStarted is equal to &#8220;on&#8221;, it will calculate that it is not &#8211; and therefore would <strong>not</strong> go through the indented code beneath it but would move onto the next set of instructions.</p>
<p>The full set of code should now look like the following:</p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO

ON = 1
OFF = 0
FORWARDS=12
BACKWARDS=11
LEFT=13
RIGHT=15
PETROL_USED_PER_MOVE=20

#variables
petrolLeft=50
engineStarted = &quot;on&quot;
lapsCompleted = 0

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(FORWARDS,GPIO.OUT)
GPIO.setup(BACKWARDS,GPIO.OUT)
GPIO.setup(LEFT,GPIO.OUT)
GPIO.setup(RIGHT,GPIO.OUT)

while engineStarted == &quot;on&quot;:
       GPIO.output(FORWARDS, ON)
       GPIO.output(RIGHT, ON)
       print(&quot;Engine running, Pi-Car should be driving in a circle&quot;)
       if (lapsCompleted &lt; 10) :
              print(&quot;Staring a new lap, laps completed&quot;,lapsCompleted)
              time.sleep(3)
              lapsCompleted = lapsCompleted + 1
       else :
              print(&quot;Laps done = &quot;,lapsCompleted,&quot; race finished lets turn off the Pi-Car&quot;)
              GPIO.output(FORWARDS,OFF)
              GPIO.output(RIGHT,OFF)
              GPIO.cleanup()
              engineStarted = &quot;off&quot;

</pre>
<p>If you run the program you will now see that 10 laps are completed before the program exits the while loop as the engineStarted variable is changed. Pi-Car then stops. When you run the code change some of the variables &#8211; like the number of laps and see what happens.</p>
<ul>
<li><strong>Driving Lesson review</strong></li>
</ul>
<p><strong>while statements:</strong></p>
<p><em><strong>How to use:</strong></em></p>
<p>1. Use the word &#8216;while&#8217; followed by a statement. This statement should be evaluated and if correct, (or true) the indented lines of code below it should be executed one by one. When it reaches the last one, it will check whether the while statement is still true and then execute each line one by one:</p>
<pre class="brush: python; title: ; notranslate">
engineStarted = &quot;on&quot;
lapsCompleted = 0

while engineStarted == &quot;on&quot;:
       GPIO.output(FORWARDS, ON)
       GPIO.output(RIGHT, ON)
       print(&quot;Engine running, Pi-Car should be driving in a circle&quot;)
       if (lapsCompleted &lt; 10) :
              print(&quot;Staring a new lap, laps completed&quot;,lapsCompleted)
              time.sleep(3)
              lapsCompleted = lapsCompleted + 1
       else :
              print(&quot;Laps done = &quot;,lapsCompleted,&quot; race finished lets turn off the Pi-Car&quot;)
              GPIO.output(FORWARDS,OFF)
              GPIO.output(RIGHT,OFF)
              GPIO.cleanup()
              engineStarted = &quot;off&quot;
</pre>
<p><span style="line-height:1.5;">2. The thing you are checking will normally be a variable on the left compared to a value, or the value of a variable, on the right hand side.</span></p>
<p><em><strong>Why do they help?</strong></em></p>
<p>1. While loops are really helpful for not having to write extra lines in your program yourself. The while loop will do this for you and will also check on each loop whether it should continue based on.</p>
<ul>
<li><strong>Gotcha&#8217;s</strong></li>
</ul>
<p>In any engineering things rarely work first time so don&#8217;t worry. Hopefully the list below will help. If not email us at info@pi-cars.com and leave a comment providing your code and what you tried to do, the solution will be obvious as soon as you see it!</p>
<ol>
<li>Remember after an while statement you need to have a colon and then indent the lines you want the Raspberry Pi to execute if the statement is true. You can indent by pressing the tab at the start of the line.</li>
<li>Remember that you need to run Python (or idle 3) as sudo to interact with the GPIO pins.</li>
<li>When you are checking a variable is the same as a string make sure you put  the speech marks around the things you are comparing. For example engineStarted == &#8220;on&#8221; is correct engineStarted == on will not be correct.</li>
</ol>
<p>Next -&gt; Driving Lesson #6 More logic &#8211; Emergency Stops and procedures</p>
<p><a title="Python if else statements – Driving Lesson #4" href="http://pi-cars.com/2013/03/03/python-if-statements-driving-lesson-4/">Previous -&gt; Driving Lesson  #4 &#8211; Python If statements</a></p>
<h3>PDF Version</h3>
<p>PDF version of this article - <a href="http://barnabypaulkent.files.wordpress.com/2013/04/python-while-loops-e28093-driving-lesson-5-_-pi-cars.pdf">Python while loops – Driving lesson #5 _ Pi-Cars</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/barnabypaulkent.wordpress.com/962/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/barnabypaulkent.wordpress.com/962/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=962&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pi-cars.com/2013/03/04/python-while-loops-driving-lesson-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/bf149e636959abaa09b15d619258b985?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barnabypaulkent</media:title>
		</media:content>
	</item>
		<item>
		<title>Python if else statements &#8211; Driving Lesson #4</title>
		<link>http://pi-cars.com/2013/03/03/python-if-statements-driving-lesson-4/</link>
		<comments>http://pi-cars.com/2013/03/03/python-if-statements-driving-lesson-4/#comments</comments>
		<pubDate>Sun, 03 Mar 2013 10:32:05 +0000</pubDate>
		<dc:creator>Barnaby Kent</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Under the bonnet]]></category>
		<category><![CDATA[pi-car]]></category>
		<category><![CDATA[pi-cars]]></category>
		<category><![CDATA[python driving lesson]]></category>
		<category><![CDATA[python driving lesson 4]]></category>
		<category><![CDATA[under the bonnet]]></category>

		<guid isPermaLink="false">http://pi-cars.com/?p=947</guid>
		<description><![CDATA[Pre-driving checks If you are here you should be able use an editor to write Python code to control  your Pi-Car and understand what we mean when we talk about constants, variables and print statements. If not by all means &#8230; <a href="http://pi-cars.com/2013/03/03/python-if-statements-driving-lesson-4/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=947&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<ul style="position:static;z-index:auto;">
<li><strong>Pre-driving checks</strong></li>
</ul>
<p>If you are here you should be able use an editor to write Python code to control  your Pi-Car and understand what we mean when we talk about constants, variables and print statements. If not by all means have a go at this lesson but if you get stuck try <a title="Pi-Cars and Python – Driving Lesson #1" href="http://pi-cars.com/2013/01/10/pi-cars-and-python-driving-lesson-1/">Driving Lesson#1</a>, <a title="Introduction to Python, constants and print statements – Driving Lesson #2" href="http://pi-cars.com/2013/02/15/introduction-to-programming/">Driving Lesson#2</a> or <a title="Variables and commenting – Driving Lesson #3" href="http://pi-cars.com/2013/03/01/variables-and-while-loops-driving-lesson-3/">Driving Lesson#3</a>.</p>
<ul>
<li><strong>What&#8217;s in this driving lesson?</strong></li>
</ul>
<p>In this lesson we will be introducing logic &#8211; rather than the Raspberry Pi just carrying out each instruction in the program one after another as it has done so far, we can make it a bit cleverer.  We do this by adding logical instructions to the program that tell the Raspberry Pi to only do certain things based on what is happening at a certain time.</p>
<p>To do this we will introduce the concept of an if instruction and the else instruction.</p>
<p>This is where you may start to see how powerful programming can be. If you get to the end and still don&#8217;t really see why it is important, again don&#8217;t worry, just trust us that they are important! As you do more you will begin to see the power these instructions will give you to do increasingly complicated things.</p>
<ul>
<li><strong>A little theory</strong></li>
</ul>
<p>Unless you already know what an if instruction is you probably do need to read the theory section this time &#8211; but I am sure this won&#8217;t stop you jumping down to the driving part! As always if you get stuck come back and have a read when you do, or just to refresh your mind, it may take a while to get these concepts.</p>
<p><em><strong>if instructions (also known as &#8216;if statements&#8217;)</strong></em></p>
<p>In the real world we have to make all sorts of decisions every day. Which decision we make depends on certain factors. For example a decision that (some) people have to make is -</p>
<p>&#8216;Should I buy a Ferrari or a Mercedes today?&#8217;</p>
<p>There are probably loads of things they have to consider when making this decision but let&#8217;s just imagine it depends on whether they have enough money:</p>
<p>&#8216;If I have enough money then buy a Ferrari, if I don&#8217;t then buy a Mercedes&#8217;</p>
<p><span style="line-height:1.5;">This is of course a much simplified version of how we may make a decision but demonstrates us (as humans) performing logical steps to make decisions and instruct ourselves to do certain things. </span></p>
<p><span style="line-height:1.5;">It follows that to make our program more intelligent we need give it the ability to make logical decisions &#8211; we don&#8217;t just want the Raspberry Pi to carry out all the instructions one after another but rather make decisions as to which instructions to perform.</span></p>
<p>As we have learnt, a program is a set of instructions that we have written down in advance. Therefore all of the decisions that we want the Raspberry Pi to make, and what happens on the outcome of each one, has to be written into the program.</p>
<p>To make one of these decisions in a program we make use of the &#8216;if&#8217; instruction, more commonly know as the &#8216;if&#8217; statement. There are certain rules around how we write this into  a Python program and we&#8217;ll now look at this based on the program we have been creating.</p>
<ul>
<li><strong>Lets get driving&#8230;</strong></li>
</ul>
<p>At the end of the <a title="Variables and commenting – Driving Lesson #3" href="http://pi-cars.com/2013/03/01/variables-and-while-loops-driving-lesson-3/">last driving lesson</a> we finished with the following code.</p>
<p>If you don&#8217;t know how to get the code onto your Raspberry Pi, you can either copy it typing it into your text file. Or you can copy it in - <a title="Example Pi-Cars Python Code" href="http://pi-cars.com/2013/02/28/example-pi-cars-python-code/">instructions here.</a></p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO

ON = 1
OFF = 0
FORWARDS=12
BACKWARDS=11
LEFT=13
RIGHT=15
PETROL_USED_PER_MOVE=20

#variables
petrolLeft=100
driversName=&quot;Michael&quot;

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(FORWARDS,GPIO.OUT)
GPIO.setup(BACKWARDS,GPIO.OUT)
GPIO.setup(LEFT,GPIO.OUT)
GPIO.setup(RIGHT,GPIO.OUT)

#Move car forwards
GPIO.output(FORWARDS,ON) #turn pin on
print (&quot;Moving forwards after turning on forwards GPIO pin no = &quot;, FORWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(FORWARDS,OFF) #turn pin off
#make petrolLeft it's own current value less a fixed amount
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
print (&quot;Current driver is &quot;,driversName)

#Move car backwards
GPIO.output(BACKWARDS,ON)
print (&quot;Moving backwards after turning on backwards GPIO pin no = &quot;,BACKWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(BACKWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
print (&quot;Current driver is &quot;,driversName)

#Change the driver
driversName = &quot;Minnie&quot;
print (&quot;New driver is &quot;,driversName)

#Move the car left - remember we have to move forwards as well
GPIO.output(LEFT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving left after turning on left GPIO pin no = &quot;,LEFT,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(LEFT,OFF)
GPIO.output(FORWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
print (&quot;Current driver is &quot;,driversName)

#Move the car right - rememeber we have to move forwards as well
GPIO.output(RIGHT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving right after turning on right GPIO pin no = &quot;,RIGHT,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(RIGHT,OFF)
GPIO.output(FORWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
print (&quot;Current driver is &quot;,driversName)

print(&quot;Finished moving, petrol left = &quot;, petrolLeft)
#remember to cleanup the GPIO pins
GPIO.cleanup()
</pre>
<p><em><strong>Limitations of the current program </strong></em></p>
<p>Change the petrolLeft variable at the top of the file to be 50 instead of 100:</p>
<pre class="brush: python; title: ; notranslate">
petrolLeft=50
</pre>
<p>Run the program and look at the print statements. It shows that the petrolLeft actually gets to a negative number but it keeps on instructing the car to keep going &#8211; not a very clever program.</p>
<p><em><strong>Giving the program some intelligence with the if statement</strong></em></p>
<p>To make the program better we can use an if statement to check before each time we move the Pi-Car whether there is any petrol left &#8211; if there is petrol left, move the car, if not don&#8217;t move it.</p>
<pre class="brush: python; title: ; notranslate">
#Move car forwards if there is petrol left
if (petrolLeft &gt; 0) :
        GPIO.output(FORWARDS,ON) #turn pin on
        print (&quot;Moving forwards after turning on forwards GPIO pin no = &quot;, FORWARDS,&quot; Petrol Left = &quot;,petrolLeft)
        time.sleep(3)
        GPIO.output(FORWARDS,OFF) #turn pin off
        #make petrolLeft it's own current value less a fixed amount
        petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
        print (&quot;Current driver is &quot;,driversName)

#Move car backwards
GPIO.output(BACKWARDS,ON)
print (&quot;Moving backwards after turning on backwards GPIO pin no = &quot;,BACKWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(BACKWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
</pre>
<p><span style="line-height:1.5;">You can see above we have used a symbol we have not seen before &#8211; the &#8216;&gt;&#8217; symbol. This symbol means &#8216;more than&#8217;. </span></p>
<p><span style="line-height:1.5;">So when the Raspberry Pi looks at</span><span style="line-height:1.5;"> the &#8216;if petrolLeft &gt; 0&#8242; instruction it will look at the current value of the variable petrolLeft and see if it is more than 0. We could have put any value where we put the 0 but we currently just want to check if it is more than 0.</span></p>
<p>You will see that after the &#8216;if petrolLeft &gt; 0&#8242; we also put a &#8216;:&#8217; symbol. This tells the Raspberry Pi that if it has worked out that petrolLeft is currently more than 0 it should continue and  carry out the instructions that follow which have been indented. By indented we mean the lines that have some space to the left of them, this space is created by pressing the tab key when you write the instruction.</p>
<p>So in the code above if petrolLeft is currently more than 0 all of the instruction lines up until the #Move car backwards line will be completed.</p>
<p><em><strong>Else can join an if</strong></em></p>
<p>We may also want to do something if the Raspberry Pi has worked out that petrolLeft is 0, or less than 0. The code below shows how to do this:</p>
<pre class="brush: python; title: ; notranslate">
#Move car forwards if there is petrol left
if (petrolLeft &gt; 0) :
        GPIO.output(FORWARDS,ON) #turn pin on
        print (&quot;Moving forwards after turning on forwards GPIO pin no = &quot;, FORWARDS,&quot; Petrol Left = &quot;,petrolLeft)
        time.sleep(3)
        GPIO.output(FORWARDS,OFF) #turn pin off
        #make petrolLeft it's own current value less a fixed amount
        petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
        print (&quot;Current driver is &quot;,driversName)
else :
        print (&quot;Sorry not enough petrol, petrol left=&quot;,petrolLeft)

#Move car backwards
GPIO.output(BACKWARDS,ON)
print (&quot;Moving backwards after turning on backwards GPIO pin no = &quot;,BACKWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(BACKWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
</pre>
<p>You can see that we used the word &#8216;else&#8217; followed by a comma &#8216;:&#8217; again. As with the if you need to let the Raspberry Pi know which instructions it should carry out, you do this by indenting the instructions you want it to execute.</p>
<p>You can only use an else after an if, you cannot use it on it&#8217;s own. Also remember that after an if or else only the instructions that are indented will be carried out. You can go ahead and put if and else statements in front of the rest of the code.</p>
<p><em><strong>Petrol left should never be negative!</strong></em></p>
<p>If you set the petrolLeft at the start to 30 and run the program you will notice that the petrolLeft can still get to a negative value. This is because we are currently only checking that the petrolLeft is more than 0. If it is only a little bit more then when the petrolLeft is reduced it can be reduced to less than 0.</p>
<p>To fix this we can check whether petrolLeft is more than the fixed amount that each movement takes:</p>
<pre class="brush: python; title: ; notranslate">
#Move car forwards if there is petrol left
if (petrolLeft &gt; PETROL_USED_PER_MOVE) :
        GPIO.output(FORWARDS,ON) #turn pin on
        print (&quot;Moving forwards after turning on forwards GPIO pin no = &quot;, FORWARDS,&quot; Petrol Left = &quot;,petrolLeft)
        time.sleep(3)
        GPIO.output(FORWARDS,OFF) #turn pin off
        #make petrolLeft it's own current value less a fixed amount
        petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
        print (&quot;Current driver is &quot;,driversName)
else :
        print (&quot;Sorry not enough petrol, petrol left=&quot;,petrolLeft)

#Move car backwards
GPIO.output(BACKWARDS,ON)
print (&quot;Moving backwards after turning on backwards GPIO pin no = &quot;,BACKWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(BACKWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
</pre>
<p>We used the constant PETROL_USED_PER_MOVE to do this and check that petrolLeft is more than it. If you run the program again you should now see that the petrolLeft does not go beneath 0. The code should now look as follows:</p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO

ON = 1
OFF = 0
FORWARDS=12
BACKWARDS=11
LEFT=13
RIGHT=15
PETROL_USED_PER_MOVE=20

#variables
petrolLeft=50
driversName=&quot;Michael&quot;

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(FORWARDS,GPIO.OUT)
GPIO.setup(BACKWARDS,GPIO.OUT)
GPIO.setup(LEFT,GPIO.OUT)
GPIO.setup(RIGHT,GPIO.OUT)

#Move car forwards if there is petrol left
if (petrolLeft &gt; PETROL_USED_PER_MOVE) :
	GPIO.output(FORWARDS,ON) #turn pin on
	print (&quot;Moving forwards after turning on forwards GPIO pin no = &quot;, FORWARDS,&quot; Petrol Left = &quot;,petrolLeft)
	time.sleep(3)
	GPIO.output(FORWARDS,OFF) #turn pin off
	#make petrolLeft it's own current value less a fixed amount
	petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
	print (&quot;Current driver is &quot;,driversName)
else :
	print (&quot;Sorry not enough petrol left, petrol left =&quot;,petrolLeft)

#Move car backwards if there is petrol left
if (petrolLeft &gt; PETROL_USED_PER_MOVE):
	GPIO.output(BACKWARDS,ON)
	print (&quot;Moving backwards after turning on backwards GPIO pin no = &quot;,BACKWARDS,&quot; Petrol Left = &quot;,petrolLeft)
	time.sleep(3)
	GPIO.output(BACKWARDS,OFF)
	petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
	print (&quot;Current driver is &quot;,driversName)
else :
	print (&quot;Sorry not enough petrol, petrol left =&quot;,petrolLeft)

#Change the driver
driversName = &quot;Minnie&quot;
print (&quot;New driver is &quot;,driversName)

#Move the car left if there is petrol left - remember we have to move forwards as well
if (petrolLeft &gt; PETROL_USED_PER_MOVE) :
	GPIO.output(LEFT,ON)
	GPIO.output(FORWARDS,ON)
	print (&quot;Moving left after turning on left GPIO pin no = &quot;,LEFT,&quot; Petrol Left = &quot;,petrolLeft)
	time.sleep(3)
	GPIO.output(LEFT,OFF)
	GPIO.output(FORWARDS,OFF)
	petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
	print (&quot;Current driver is &quot;,driversName)
else :
	print (&quot;Sorry not enough petrol, petrol left =&quot;, petrolLeft)

#Move the car right if there is petrol left - rememeber we have to move forwards as well
if (petrolLeft &gt; PETROL_USED_PER_MOVE) :
	GPIO.output(RIGHT,ON)
	GPIO.output(FORWARDS,ON)
	print (&quot;Moving right after turning on right GPIO pin no = &quot;,RIGHT,&quot; Petrol Left = &quot;,petrolLeft)
	time.sleep(3)
	GPIO.output(RIGHT,OFF)
	GPIO.output(FORWARDS,OFF)
	petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
	print (&quot;Current driver is &quot;,driversName)
else :
	print (&quot;Sorry not enough petrol, petrol left =&quot;, petrolLeft)

print(&quot;Finished moving, petrol left = &quot;, petrolLeft)
#remember to cleanup the GPIO pins
GPIO.cleanup()
</pre>
<p>So you have now added your first bit of logic to your program which has made it more intelligent. We&#8217;ll go on to look at other bits of logic we can add in the next driving lesson, but before we do we&#8217;ll finish this lesson by looking at some of the other ways we can make decisions.</p>
<p><em><strong>Other operators</strong></em></p>
<p>In the code we added so far we have used the &#8216;&gt;&#8217; symbol to indicate &#8216;more than&#8217; when checking if there was enough petrol left and the &#8216;-&#8217; symbol to reduce the petrol left after each time the Pi-Car moved. There are a number of other symbols like this we can use in a Python program -they are called operators. They can be used when setting variables. Some you will probably recognise already:</p>
<ul>
<li><span style="line-height:1.5;">&#8216;+&#8217; used for adding up e.g. petrolLeft = petrolLeft + 30</span></li>
<li>&#8216;-&#8217; used for subtracting e.g. petrolLeft = petrolLeft &#8211; PETROL_USED_PER_MOVE</li>
<li>&#8216;*&#8217; used for multiplying e.g. timeTaken = 30 * 20</li>
<li>&#8216;/&#8217; used for division e.g. movesLeft = petrolLeft / PETROL_USED_PER_MOVE</li>
</ul>
<p><span style="font-size:16px;line-height:1.5;">We have seen one of these already and will come on to use the remaining ones in the following lessons so don&#8217;t worry if you don&#8217;t understand how they would be used at the moment.</span></p>
<p>Other operators which you may not recognise if you have not done anything like this before are shown below. These are very useful for comparing the current value of a variable to another value like we did with the petrolLeft. They will often be used in if statements (and others that we will come onto look at).</p>
<ul>
<li><span style="line-height:16px;">&#8216;&gt;&#8217; used to check if the value on the left is &#8216;more than&#8217; the value on the right e.g. if (petrolLeft &gt; PETROL_USED_PER_MOVE)</span></li>
<li>&#8216;&lt;&#8217; used to check whether the value on the left is &#8216;less than&#8217; the value on the right</li>
<li>&#8216;&gt;=&#8217; used to check if the value on the left is &#8216;more than <strong>or</strong> equal to&#8217; the value on the right</li>
<li>&#8216;&lt;=&#8217; used to check if the value on the left is &#8216;less than <strong>or</strong> equal to&#8217; the value on the right</li>
<li>&#8216;==&#8217; used when you want to check that two variables are the same</li>
<li>&#8216;!=&#8217; used when you want to check that two variables are not the same. You can also use &lt;&gt; for this</li>
</ul>
<p>Again we will come on to actually use these in future driving lessons so at the moment just be aware that they exist and you may be able to think of some ways you could use them in your program. There are in fact even more operators than this but for the time being these will be enough and help us make our programs much more powerful.</p>
<ul>
<li><strong>Driving Lesson review</strong></li>
</ul>
<p><strong>If and else statements:</strong></p>
<p><em><strong>How to use:</strong></em></p>
<p>1. Use the word &#8216;if&#8217; followed by a statement you are checking.  If the thing you are checking is true then the lines after it which have been indented will be executed:</p>
<pre class="brush: python; title: ; notranslate">
if (petrolLeft &gt; 25) :
      print (&quot;This will be printed if the value of petrolLeft is more than 25&quot;)

print (&quot;This line will always be printed whether petrolLeft is more than 25 or not)
</pre>
<p>2. The thing you are checking will normally be a variable on the left compared to a value, or the value of a variable, on the right hand side.</p>
<p><span style="line-height:1.5;">3. You can also use the &#8216;else&#8217; instruction to carry out some instructions if the thing you were checking turned out not to be true:</span></p>
<pre class="brush: python; title: ; notranslate">
if (petrolLeft &gt; 25) :
      print (&quot;This will be printed if the value of petrolLeft is more than 25&quot;)

else :
      print (&quot;This will only be printed out if petrolLeft is less than or equal to 25&quot;)

print (&quot;This line will always be printed whether petrolLeft is more than 25 or not)
</pre>
<p><em><strong>Why do they help?</strong></em></p>
<p>1. Your program can now make decisions! It means that rather than just carrying out each instruction one after another, you can tell the Raspberry Pi to only do certain instructions in certain situations.</p>
<ul>
<li><strong>Gotcha&#8217;s</strong></li>
</ul>
<p>In any engineering things rarely work first time so don&#8217;t worry. Hopefully the list below will help. If not email us at info@pi-cars.com and leave a comment providing your code and what you tried to do, the solution will be obvious as soon as you see it!</p>
<ol>
<li><span style="line-height:16px;">Remember after an if statement you need to have a colon and then indent the lines you want the Raspberry Pi to execute if the statement is true. You can indent by pressing the tab at the start of the line.</span></li>
</ol>
<p>Next -&gt; Driving Lesson #5 More logic &#8211; While loops and Emergency Stops</p>
<p><a title="Python variables and commenting – Driving Lesson #3" href="http://pi-cars.com/2013/03/01/variables-and-while-loops-driving-lesson-3/">Previous -&gt; Driving Lesson  #3 Variables and constants</a></p>
<h3><span style="line-height:1.5;"> PDF Version </span></h3>
<p>PDF version of this article - <a href="http://barnabypaulkent.files.wordpress.com/2013/04/python-if-else-statements-e28093-driving-lesson-4-_-pi-cars.pdf">Python if else statements – Driving Lesson #4 _ Pi-Cars</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/barnabypaulkent.wordpress.com/947/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/barnabypaulkent.wordpress.com/947/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=947&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pi-cars.com/2013/03/03/python-if-statements-driving-lesson-4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/bf149e636959abaa09b15d619258b985?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barnabypaulkent</media:title>
		</media:content>
	</item>
		<item>
		<title>Python variables and commenting &#8211; Driving Lesson #3</title>
		<link>http://pi-cars.com/2013/03/01/variables-and-while-loops-driving-lesson-3/</link>
		<comments>http://pi-cars.com/2013/03/01/variables-and-while-loops-driving-lesson-3/#comments</comments>
		<pubDate>Fri, 01 Mar 2013 01:06:49 +0000</pubDate>
		<dc:creator>Barnaby Kent</dc:creator>
				<category><![CDATA[Under the bonnet]]></category>
		<category><![CDATA[driving lesson 1]]></category>
		<category><![CDATA[pi-cars]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python driving lesson]]></category>
		<category><![CDATA[python driving lesson 3]]></category>
		<category><![CDATA[under the bonnet]]></category>

		<guid isPermaLink="false">http://pi-cars.com/?p=897</guid>
		<description><![CDATA[Pre-driving checks If you are here you should be able use an editor to write Python code to control  your Pi-Car. If not by all means have a go at this lesson but if you get stuck try Driving Lesson#1 &#8230; <a href="http://pi-cars.com/2013/03/01/variables-and-while-loops-driving-lesson-3/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=897&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<ul>
<li><span style="line-height:16px;"><strong>Pre-driving checks</strong><br />
</span></li>
</ul>
<p>If you are here you should be able use an editor to write Python code to control  your Pi-Car. If not by all means have a go at this lesson but if you get stuck try <a title="Pi-Cars and Python – Driving Lesson #1" href="http://pi-cars.com/2013/01/10/pi-cars-and-python-driving-lesson-1/">Driving Lesson#1</a> or <a title="Introduction to Python, constants and print statements – Driving Lesson #2" href="http://pi-cars.com/2013/02/15/introduction-to-programming/">Driving Lesson#2.</a></p>
<ul>
<li><strong style="line-height:1.5;">What&#8217;s in this driving lesson?</strong></li>
</ul>
<p><span style="font-size:medium;"><span style="line-height:24px;">In this lesson we will be considering things called variables and comments. As with the last lesson you may get to the end and still wonder why you need them and why they are important. However, stick with it, when you get to the next Driving lesson and the start of logic it will become clearer.</span></span></p>
<ul>
<li><span style="line-height:16px;"><strong>A little theory</strong><br />
</span></li>
</ul>
<p>We will start with a bit of theory again, so most of you will probably skip this bit and go down to the actual doing part but do come back if you don&#8217;t understand it!</p>
<p><em><strong>Variables</strong></em></p>
<p>So what is a variable? In the last <a title="Pi-Cars and Python – Driving Lesson #1" href="http://pi-cars.com/2013/01/10/pi-cars-and-python-driving-lesson-1/">Driving Lesson</a> we learnt about a constant. A variable is similar to a constant in that it is something that holds a value but as the name suggests this value can vary.</p>
<p>This means that as the Raspberry Pi works through the instructions in the program one by one a variable can hold a certain value at one stage in the program but a different value at another stage.</p>
<p>As with a constant, in programming you have the variable name on the left side followed by a &#8216;=&#8217; symbol and then a value on the right side of it. For example:</p>
<p>petrolLeft = 100</p>
<p>This variable might be used to indicate how much petrol is left as your program runs. Here it is being set to 100 initially,  it can then be set to a different value later.</p>
<p>Also pay attention to the variable name, even though it is two words &#8211; petrol and left &#8211; there is no space between them. This is one of the rules of the Python language &#8211; you cannot have spaces in variables. With this variable you will see we put a capital on the second word in order to make it easier to read. This is a common trick to use.</p>
<p><em><strong>Variable types</strong></em></p>
<p>Before we get driving we do just need to consider the different types of variables. The one  we used above was obviously a number but we can also have a variable that have a word, or a number of words associated to it. This is referred to as a String &#8211; as in a string of letters. If we want to assign a string we need to put speech marks around it so the Raspberry Pi knows what we mean:</p>
<p>carDriver = &#8220;Michael&#8221;</p>
<ul>
<li><span style="line-height:16px;"><strong>Lets get driving&#8230;</strong><br />
</span></li>
</ul>
<p>Enough of the theory (for those of you who read it) let&#8217;s try and drive our Pi-Car and use some variables. At the end of the <a title="Introduction to Python, constants and print statements – Driving Lesson #2" href="http://pi-cars.com/2013/02/15/introduction-to-programming/">last driving lesson</a> we finished with the following code.</p>
<p>If you don&#8217;t know how to get the code onto your Raspberry Pi, you can either copy it typing it into your text file. Or you can copy it in &#8211; <a title="Example Pi-Cars Python Code" href="http://pi-cars.com/2013/02/28/example-pi-cars-python-code/">instructions here.</a></p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO
ON = 1
OFF = 0
FORWARDS=12
BACKWARDS=11
LEFT=13
RIGHT=15

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(FORWARDS,GPIO.OUT)
GPIO.setup(BACKWARDS,GPIO.OUT)
GPIO.setup(LEFT,GPIO.OUT)
GPIO.setup(RIGHT,GPIO.OUT)

GPIO.output(FORWARDS,ON)
print (&quot;Moving forwards after turning on forwards GPIO pin no = &quot;, FORWARDS)
time.sleep(3)
GPIO.output(FORWARDS,OFF)
GPIO.output(BACKWARDS,ON)
print (&quot;Moving backwards after turning on backwards GPIO pin no = &quot;,BACKWARDS)
time.sleep(3)
GPIO.output(BACKWARDS,OFF)

GPIO.output(LEFT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving left after turning on left GPIO pin no = &quot;,LEFT)
time.sleep(3)
GPIO.output(LEFT,OFF)
GPIO.output(FORWARDS,OFF)

GPIO.output(RIGHT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving right after turning on right GPIO pin no = &quot;,RIGHT)
time.sleep(3)
GPIO.output(RIGHT,OFF)
GPIO.output(FORWARDS,OFF)
</pre>
<p>In this code the car should move forwards, wait for a bit, move backwards, wait for a bit, move forwards and left, wait for a bit and then move forwards and right and wait for a bit. It will also print out what it is doing to the screen.</p>
<p><strong><em>Adding a variable</em></strong></p>
<p>So lets add a variable. We will add a variable that stores how much petrol is left and then reduce it as the car moves which we can then print out. Put it just beneath the constants you created.</p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO
ON = 1
OFF = 0
FORWARDS=12
BACKWARDS=11
LEFT=13
RIGHT=15

petrolLeft = 100

</pre>
<p>Now we have our variable let&#8217;s print out the value &#8211; as we did with the constants:</p>
<pre class="brush: python; title: ; notranslate">
print (&quot;Moving forwards after turning on forwards GPIO pin no = &quot;, FORWARDS, &quot; Petrol left = &quot;,petrolLeft)

</pre>
<p>If you can remember we need to add any words we want to print out in speech marks when we do a print and if we want to print out the value of a variable or constant add a &#8216;,&#8217; and then the variable name.</p>
<p>Add the part above that prints out the Petrol Left value to each print statement in the code. You should now have the following:</p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO
ON = 1
OFF = 0
FORWARDS=12
BACKWARDS=11
LEFT=13
RIGHT=15
petrolLeft=100

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(FORWARDS,GPIO.OUT)
GPIO.setup(BACKWARDS,GPIO.OUT)
GPIO.setup(LEFT,GPIO.OUT)
GPIO.setup(RIGHT,GPIO.OUT)

GPIO.output(FORWARDS,ON)
print (&quot;Moving forwards after turning on forwards GPIO pin no = &quot;, FORWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(FORWARDS,OFF)
GPIO.output(BACKWARDS,ON)
print (&quot;Moving backwards after turning on backwards GPIO pin no = &quot;,BACKWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(BACKWARDS,OFF)

GPIO.output(LEFT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving left after turning on left GPIO pin no = &quot;,LEFT,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(LEFT,OFF)
GPIO.output(FORWARDS,OFF)

GPIO.output(RIGHT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving right after turning on right GPIO pin no = &quot;,RIGHT,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(RIGHT,OFF)
GPIO.output(FORWARDS,OFF)
</pre>
<p>If you now save this file and run it you should see it print out the same value for petrol left each time it moves which obviously isn&#8217;t right as when a car moves it uses up petrol (yes I know they are batteries in a Pi-Car!).</p>
<p><em><strong>Changing the value of a variable</strong></em></p>
<p>So what we want to do is change the value of the petrolLeft variable after each time it moves. To do this we could set it to a different value each time. For example we could say each movement reduces the petrolLeft by 20, so after the first one we could assign petrolLeft to 80.</p>
<pre class="brush: python; title: ; notranslate">

GPIO.output(FORWARDS,ON)
print (&quot;Moving forwards after turning on forwards GPIO pin no = &quot;, FORWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(FORWARDS,OFF)

petrolLeft = 80

</pre>
<p>So when petrol left is printed out the first time it will print out 100, the next time it will print out 80.</p>
<p>Doing this, we have to work out the value each time throughout the file. It would be easier for us to just say lets take 20 off the current value of petrolLeft and we can do this quite easily by typing:</p>
<p>petrolLeft = petrolLeft &#8211; 20</p>
<p>What we are doing here is saying the value of petrolLeft should be whatever the value it is at the moment &#8211; which at the start of the file is 100 &#8211; and then take 20 away from it. This will then mean that petrolLeft will then be assigned the value 80 (100 &#8211; 20).</p>
<p>Doing this means we do not have to work out the value ourselves &#8211; which will be very useful when things get more complicated.</p>
<p>What you may notice is that you are still typing in the number 20 a number of times always the same value &#8211; so why don&#8217;t we make it a constant? If we do this it means if we want to change it at some point we will only have to change it in one place.</p>
<p>Lets define the constant PETROL_USED_PER_MOVE with the other constants:</p>
<pre class="brush: python; title: ; notranslate">
ON = 1
OFF = 0
FORWARDS=12
BACKWARDS=11
LEFT=13
RIGHT=15
PETROL_USED_PER_MOVE=20

petrolLeft = 100

</pre>
<p><span style="line-height:1.5;">And then use it when we are calculating the petrolLeft value:</span></p>
<p>petrolLeft = petrolLeft &#8211; PETROL_USED_PER_MOVE</p>
<p>So this should mean you now have the following:</p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO
ON = 1
OFF = 0
FORWARDS=12
BACKWARDS=11
LEFT=13
RIGHT=15
PETROL_USED_PER_MOVE=20
petrolLeft=100

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(FORWARDS,GPIO.OUT)
GPIO.setup(BACKWARDS,GPIO.OUT)
GPIO.setup(LEFT,GPIO.OUT)
GPIO.setup(RIGHT,GPIO.OUT)

GPIO.output(FORWARDS,ON)
print (&quot;Moving forwards after turning on forwards GPIO pin no = &quot;, FORWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(FORWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE

GPIO.output(BACKWARDS,ON)
print (&quot;Moving backwards after turning on backwards GPIO pin no = &quot;,BACKWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(BACKWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE

GPIO.output(LEFT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving left after turning on left GPIO pin no = &quot;,LEFT,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(LEFT,OFF)
GPIO.output(FORWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE

GPIO.output(RIGHT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving right after turning on right GPIO pin no = &quot;,RIGHT,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(RIGHT,OFF)
GPIO.output(FORWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE

print(&quot;Finished moving, petrol left = &quot;, petrolLeft)
</pre>
<p>Run your program and you should see it print out that the petrol is decreasing as your car moves. Also note that if you run your program again the petrolLeft variable will be set to 100 again because the Raspberry Pi executes each instruction in the program. It will not remember the value from the last time you ran it.</p>
<p><em><strong>Adding a different type of variable</strong></em></p>
<p>In the theory section we also introduced the idea that variables didn&#8217;t just have to store numbers they could also store a word these are referred to as Strings. So lets add a string variable where we will store the drivers name which we will called driversName:</p>
<pre class="brush: python; title: ; notranslate">
ON = 1
OFF = 0
FORWARDS=12
BACKWARDS=11
LEFT=13
RIGHT=15
PETROL_USED_PER_MOVE=20

petrolLeft = 100
driversName = &quot;Michael&quot;

</pre>
<p><span style="line-height:1.5;">We can now print out the drivers name whenever we want:</span></p>
<pre class="brush: python; title: ; notranslate">

print (&quot;Current drivers name is &quot;,driversName)

</pre>
<p>If we want to change the drivers name halfway through we can do this by typing in the variable name and assigning it a new value:</p>
<pre class="brush: python; title: ; notranslate">

print (&quot;Current drivers name is &quot;,driversName)
print (&quot;Changing driver now&quot;)
driversName = &quot;Minnie&quot;
print (&quot;New driver is&quot;,driversName)

</pre>
<p>This will now print out the new drivers name and y<span style="line-height:1.5;">our code should now look like the following:</span></p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO
ON = 1
OFF = 0
FORWARDS=12
BACKWARDS=11
LEFT=13
RIGHT=15
PETROL_USED_PER_MOVE=20
petrolLeft=100
driversName=&quot;Michael&quot;

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(FORWARDS,GPIO.OUT)
GPIO.setup(BACKWARDS,GPIO.OUT)
GPIO.setup(LEFT,GPIO.OUT)
GPIO.setup(RIGHT,GPIO.OUT)

GPIO.output(FORWARDS,ON)
print (&quot;Moving forwards after turning on forwards GPIO pin no = &quot;, FORWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(FORWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
print (&quot;Current driver is &quot;,driversName)

GPIO.output(BACKWARDS,ON)
print (&quot;Moving backwards after turning on backwards GPIO pin no = &quot;,BACKWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(BACKWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
print (&quot;Current driver is &quot;,driversName)
driversName = &quot;Minnie&quot;
print (&quot;New driver is &quot;,driversName)

GPIO.output(LEFT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving left after turning on left GPIO pin no = &quot;,LEFT,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(LEFT,OFF)
GPIO.output(FORWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
print (&quot;Current driver is &quot;,driversName)

GPIO.output(RIGHT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving right after turning on right GPIO pin no = &quot;,RIGHT,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(RIGHT,OFF)
GPIO.output(FORWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
print (&quot;Current driver is &quot;,driversName)

print(&quot;Finished moving, petrol left = &quot;, petrolLeft)
</pre>
<p><span style="line-height:1.5;">When you run the code you should see the petrol reducing as the car moves and the name of the driver changing.</span></p>
<p><em><strong>Comments make it easier</strong></em></p>
<p>The final thing in this lesson is to learn about comments. When looking at computer code it is sometimes quite difficult to understand. You can make it easier by adding something called comments to your code.</p>
<p>These are lines that you can add which are only for people looking at it and are not meant for the Raspberry Pi to try and do anything with. However, to make sure the Raspberry Pi does not do anything with the line we type we have to tell it not to look any further. We do this by adding a &#8216;#&#8217; (hash) symbol.</p>
<pre class="brush: python; title: ; notranslate">
#make petrolLeft it's own current value less a fixed amount
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
</pre>
<p>The # symbol means that the Raspberry Pi will not bother looking at the rest of the line and will skip onto the next one so you can type what you like.</p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO

ON = 1
OFF = 0
FORWARDS=12
BACKWARDS=11
LEFT=13
RIGHT=15
PETROL_USED_PER_MOVE=20

#variables
petrolLeft=100
driversName=&quot;Michael&quot;

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(FORWARDS,GPIO.OUT)
GPIO.setup(BACKWARDS,GPIO.OUT)
GPIO.setup(LEFT,GPIO.OUT)
GPIO.setup(RIGHT,GPIO.OUT)

#Move car forwards
GPIO.output(FORWARDS,ON) #turn pin on
print (&quot;Moving forwards after turning on forwards GPIO pin no = &quot;, FORWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(FORWARDS,OFF) #turn pin off
#make petrolLeft it's own current value less a fixed amount
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
print (&quot;Current driver is &quot;,driversName)

#Move car backwards
GPIO.output(BACKWARDS,ON)
print (&quot;Moving backwards after turning on backwards GPIO pin no = &quot;,BACKWARDS,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(BACKWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
print (&quot;Current driver is &quot;,driversName)

#Change the driver
driversName = &quot;Minnie&quot;
print (&quot;New driver is &quot;,driversName)

#Move the car left - remember we have to move forwards as well
GPIO.output(LEFT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving left after turning on left GPIO pin no = &quot;,LEFT,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(LEFT,OFF)
GPIO.output(FORWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
print (&quot;Current driver is &quot;,driversName)

#Move the car right - rememeber we have to move forwards as well
GPIO.output(RIGHT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving right after turning on right GPIO pin no = &quot;,RIGHT,&quot; Petrol Left = &quot;,petrolLeft)
time.sleep(3)
GPIO.output(RIGHT,OFF)
GPIO.output(FORWARDS,OFF)
petrolLeft = petrolLeft - PETROL_USED_PER_MOVE
print (&quot;Current driver is &quot;,driversName)

print(&quot;Finished moving, petrol left = &quot;, petrolLeft)
#remember to cleanup the GPIO pins
GPIO.cleanup()
</pre>
<p><span style="line-height:1.5;">The above code shows some comments which makes it a bit easier to understand. As with the other things we are learning, these become more important as things get more complicated.</span></p>
<p>You may also have notice that you do not have to put the # symbol at the start of the line. You can put it half way through the line. This will not mean the Raspberry Pi will ignore the whole line it will only ignore <strong>anything after</strong> the hash.</p>
<ul>
<li><strong style="line-height:1.5;">Driving Lesson review</strong></li>
</ul>
<p><strong>Variables:</strong></p>
<p><em><strong>How to use:</strong></em></p>
<p>1. <span style="line-height:16px;">Put the name on the left and the value on the right and choose a suitable name &#8211; the same as constants. Remember no spaces, and also the convention is to </span><strong style="line-height:16px;">not</strong><span style="line-height:16px;"> use all upper case for variables:</span></p>
<pre class="brush: python; title: ; notranslate">
petrolLeft = 100
</pre>
<p><span style="line-height:1.5;">2. Unlike constants at a different point in the program you can then assign a different value to the variable.</span></p>
<p>3. Also remember you can use the variable itself when you are changing it&#8217;s value.</p>
<pre class="brush: python; title: ; notranslate">
petrolLeft = petrolLeft - 20
</pre>
<p><em><strong>Why do they help?</strong></em></p>
<p>1. You can use them to store things that change that you will want to use in your program &#8211; you will see the real use in the next few Driving Lessons.</p>
<p><strong>Comments:</strong></p>
<p><em><strong>How to use:</strong></em></p>
<p>1. Put a # symbol and then write any useful comment after it on the same line</p>
<pre class="brush: python; title: ; notranslate">
#reduce the petrol left by its current value less 20
petrolLeft = petrolLeft - 20
</pre>
<p><em><strong>Why do they help?</strong></em></p>
<p>1. They make the code easier to understand</p>
<ul>
<li><strong>Gotcha&#8217;s</strong></li>
</ul>
<p>In any engineering things rarely work first time so don&#8217;t worry. Hopefully the list below will help. If not email us at info@pi-cars.com and leave a comment providing your code and what you tried to do, the solution will be obvious as soon as you see it!</p>
<p><a title="Python if statements – Driving Lesson #4" href="http://pi-cars.com/2013/03/03/python-if-statements-driving-lesson-4/">Next -&gt; Driving Lesson #4 If statements</a></p>
<p><a title="Introduction to Python, constants and print statements – Driving Lesson #2" href="http://pi-cars.com/2013/02/15/introduction-to-programming/">Previous -&gt; Driving Lesson #2 Pi-Cars and Python</a></p>
<h3>PDF Version</h3>
<p>PDF version of this article - <a href="http://barnabypaulkent.files.wordpress.com/2013/04/python-variables-and-commenting-e28093-driving-lesson-3-_-pi-cars.pdf">Python variables and commenting – Driving Lesson #3 _ Pi-Cars</a><a href="http://barnabypaulkent.files.wordpress.com/2013/04/introduction-to-python-constants-and-print-statements-e28093-driving-lesson-2-_-pi-cars.pdf"><br />
</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/barnabypaulkent.wordpress.com/897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/barnabypaulkent.wordpress.com/897/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=897&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pi-cars.com/2013/03/01/variables-and-while-loops-driving-lesson-3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/bf149e636959abaa09b15d619258b985?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barnabypaulkent</media:title>
		</media:content>
	</item>
		<item>
		<title>Example Pi-Cars Python Code</title>
		<link>http://pi-cars.com/2013/02/28/example-pi-cars-python-code/</link>
		<comments>http://pi-cars.com/2013/02/28/example-pi-cars-python-code/#comments</comments>
		<pubDate>Thu, 28 Feb 2013 22:07:25 +0000</pubDate>
		<dc:creator>Barnaby Kent</dc:creator>
				<category><![CDATA[Under the bonnet]]></category>
		<category><![CDATA[driving lesson]]></category>
		<category><![CDATA[pi-cars]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python driving lesson]]></category>
		<category><![CDATA[under the bonnet]]></category>

		<guid isPermaLink="false">http://pi-cars.com/?p=916</guid>
		<description><![CDATA[This code will be incorporated into the Driving Lessons in due course but in the meantime here is some Python code that will work with your Pi-Car. How to get the code onto your Raspberry Pi and run it To &#8230; <a href="http://pi-cars.com/2013/02/28/example-pi-cars-python-code/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=916&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This code will be incorporated into the Driving Lessons in due course but in the meantime here is some Python code that will work with your Pi-Car.</p>
<ul>
<li><span style="line-height:16px;"><strong>How to get the code onto your Raspberry Pi and run it</strong><br />
</span></li>
</ul>
<p>To select the code and use it:</p>
<ul>
<li>Visit this page on your Raspberry Pi with the browser</li>
<li><span style="line-height:1.5;">Move your cursor over the code segments below and in the top right corner a &lt;&gt; should appear. </span></li>
<li><span style="line-height:1.5;">Click on it and a new window should open with all the code in it. </span></li>
<li><span style="line-height:1.5;">Select it all with the mouse or click CTR + A.</span></li>
<li>Copy it by clicking CTR + C or right click and select copy.</li>
<li>Minimize the browser to reveal the desktop.</li>
<li>Open up a command prompt by double clicking on the LX terminal on the desktop.</li>
<li>Open a text editor using a command like &#8216;nano PiCarTest.py&#8217;</li>
<li>Paste the clipboard into the text file by right clicking and choosing paste.</li>
<li>Save the file (in nano CTR + X, then type &#8216;y&#8217; then press enter).</li>
</ul>
<p>You can then run with the command:</p>
<pre class="brush: bash; title: ; notranslate">sudo python PiCarTest.py</pre>
<ul>
<li><span style="line-height:16px;"><strong>Example Python code</strong><br />
</span></li>
</ul>
<p>Here is a file which has variables, constants, while loops, if else and procedures (you may know them as methods or functions). There are also some comments! :</p>
<pre class="brush: python; title: ; notranslate">
#!/usr/bin/env python

&quot;&quot;&quot; Must be run as root - sudo python PicarsFunctions.py &quot;&quot;&quot;

import time, datetime, RPi.GPIO as GPIO

FORWARD=12
BACK=11
LEFT=13
RIGHT=15
TURBO=7

GPIO.setmode(GPIO.BOARD)
#Remember to setup the GPIO pin as input or output
GPIO.setup(FORWARD, GPIO.OUT)
GPIO.setup(BACK, GPIO.OUT)
GPIO.setup(LEFT, GPIO.OUT)
GPIO.setup(RIGHT, GPIO.OUT)

def print_time(): #prints out the time now in a format we like
    #print &quot;Time before statement is run&quot;
    print datetime.datetime.now()

def forwards_on(): #turns the forwards pin on
    print &quot;About to turn forwards pin on&quot;
    print_time()
    #turn back off as well
    backwards_off()
    GPIO.output(FORWARD,1)

def forwards_off(): #turns the forwards pin off
    print &quot;About to turn forwards pin off&quot;
    print_time()
    GPIO.output(FORWARD,0)

def backwards_on(): #turns backwards pin on
    print &quot;About to turn the backwards pin on&quot;
    print_time()
    #turn forwards off as well
    forwards_off()
    GPIO.output(BACK,1)

def backwards_off(): #turns backwards pin off
    print &quot;About to turn the backwards pin off&quot;
    print_time()
    GPIO.output(BACK,0)

def left_on(): #turns the left pin on
    print &quot;About to turn the left pin on&quot;
    print_time()
    #turn right off as well
    right_off()
    GPIO.output(LEFT,1)

def left_off(): #turns the left pin off
    print &quot;About to turn the left pin off&quot;
    print_time()
    GPIO.output(LEFT,0)

def right_on(): #turns the right pin on
    print &quot;About to turn the right pin on&quot;
    print_time()
    #turn left off as well
    left_off()
    GPIO.output(RIGHT,1)

def right_off(): #turns the right pin off
    print &quot;About tot turn the right pin off&quot;
    print_time()
    GPIO.output(RIGHT,0)

def choose_dir(dirWanted=LEFT):
    if dirWanted == LEFT:
        right_off()
        left_on()
    else:
        left_off()
        right_on()

def straighten():
    print &quot;About to straighten&quot;
    print_time()
    left_off()
    right_off()

def slalom(startSideDir=RIGHT,startDir=FORWARD,turns=4, interval=0.1): #does a slalom by default starting right and doing it 4 times with an interval of 0.1
    i = 0
    #need to determine which way we should be going with the direction
    if startDir == FORWARD:
        print &quot;Going to move forwards in the slalom&quot;
        print_time()
        forwards_on()
    else:
        print &quot;Going to move backwards in the slalom&quot;
        print_time()
        backwards_on()
    #now do the turns
    while i &lt; turns:
        print &quot;about to slalom to = &quot;, startSideDir
        choose_dir(startSideDir)
        print &quot;Left direction&quot;, LEFT
        print &quot;Right direction&quot;, RIGHT
        print_time()
        if i == 0:
            #the first turn should only be half the amount
            time.sleep(interval/2)
        else:
            time.sleep(interval)
        #toggle direction for next time
        if startSideDir == RIGHT:
            startSideDir = LEFT
        else:
            startSideDir = RIGHT
        i = i + 1
    #at the end straighten the wheels
    straighten()

def all_off(): #turns all of the pins off - always call at the end to save battery <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> 
    GPIO.output(FORWARD,0)
    GPIO.output(BACK,0)
    GPIO.output(LEFT,0)
    GPIO.output(RIGHT,0)

def cleanup(): #cleans up the GPIO pins
    GPIO.cleanup()

def sleep(sleepTime=1):
    time.sleep(sleepTime)

def main():
    try:
        forwards_on()
#        sleep(0.6)
#        right_on()
        sleep(0.5)
        #all_off()
        slalom(LEFT,FORWARD,400,0.5)
        sleep(0.5)
        all_off()
        sleep(0.5)
        #time.sleep(0.4)
        #backwards_on()
        #time.sleep(1)
        slalom(LEFT,BACK,4,0.5)
        sleep(0.5)
        #forwards_on()
        #time.sleep(1)
        #right_on()
        #time.sleep(0.5)
        #right_off()
        #time.sleep(0.5)
        #left_on()
        #time.sleep(0.5)
        #left_off()
        #time.sleep(0.5)
        #forwards_off()
        #time.sleep(0.5)
        #backwards_on()
        #time.sleep(1)
        all_off()
        cleanup()
    except KeyboardInterrupt:
        cleanup()

if __name__ == &quot;__main__&quot;:
    main()

</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/barnabypaulkent.wordpress.com/916/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/barnabypaulkent.wordpress.com/916/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=916&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pi-cars.com/2013/02/28/example-pi-cars-python-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/bf149e636959abaa09b15d619258b985?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barnabypaulkent</media:title>
		</media:content>
	</item>
		<item>
		<title>Introduction to Python, constants and print statements &#8211; Driving Lesson #2</title>
		<link>http://pi-cars.com/2013/02/15/introduction-to-programming/</link>
		<comments>http://pi-cars.com/2013/02/15/introduction-to-programming/#comments</comments>
		<pubDate>Fri, 15 Feb 2013 21:18:03 +0000</pubDate>
		<dc:creator>Barnaby Kent</dc:creator>
				<category><![CDATA[Under the bonnet]]></category>
		<category><![CDATA[constants]]></category>
		<category><![CDATA[driving lesson]]></category>
		<category><![CDATA[pi-cars]]></category>
		<category><![CDATA[print statement]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python driving lesson]]></category>
		<category><![CDATA[python driving lesson 2]]></category>
		<category><![CDATA[under the bonnet]]></category>

		<guid isPermaLink="false">http://pi-cars.com/?p=782</guid>
		<description><![CDATA[Pre-driving checks If you are here you should have set up your Raspberry Pi,  understand how to connect your Pi-Car to your Raspberry Pi and know how to use IDLE or another editor to write Python code and run it. &#8230; <a href="http://pi-cars.com/2013/02/15/introduction-to-programming/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=782&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<ul>
<li><strong><span style="line-height:16px;">Pre-driving checks</span></strong></li>
</ul>
<p>If you are here you should have set up your Raspberry Pi,  understand how to connect your Pi-Car to your Raspberry Pi and know how to use IDLE or another editor to write Python code and run it. If not don&#8217;t worry:</p>
<p>For more information on setting up your Raspberry Pi <a title="Set up your Raspberry Pi" href="http://pi-cars.com/2012/12/19/set-up-your-raspberry-pi/">click here</a>.</p>
<p>For more information on how to connect your Pi-Car to your Raspberry Pi <a title="Jump start – get your Pi-Car going as quickly as you can" href="http://pi-cars.com/2012/12/22/jump-start-get-your-pi-car-going-as-quick-as-you-can#jumpstart-connect-pi-car-up">click here.</a></p>
<p>For more information on how to start-up and use the IDLE3 editor to write and run Python code <a title="Pi-Cars and Python – Driving Lesson #1" href="http://pi-cars.com/2013/01/10/pi-cars-and-python-driving-lesson-1#pythoneditor">click here</a>.</p>
<p>We would also recommend that you have completed the <a title="Pi-Cars and Python – Driving Lesson #1" href="http://pi-cars.com/2013/01/10/pi-cars-and-python-driving-lesson-1/">Pi-Cars Driving Lesson #1</a> where you do a quick test with Pi-Car to check everything is working and you can see how to actually write a Python program and then run it.</p>
<ul>
<li><strong>What&#8217;s in this driving lesson?</strong></li>
</ul>
<p><span style="font-size:16px;">By now you will have written a few lines of code and run it to make the wheels move on the Pi-Car but you may not have understood much. This lesson introduces a bit more about what a program is and the concept of constants.</span></p>
<ul>
<li><span style="line-height:16px;"><strong>A little theory</strong><br />
</span></li>
</ul>
<p>Much like real driving, we do need some theory in order to understand how to drive a Pi-Car and get the most out of it. I am sure lots of you will just skip this section and get onto the <a title="Lets get driving" href="#letsgetdriving">actual driving part</a>, however, do come back and read on if you are at all unsure as you do need to understand the concepts here in order to be able to program.</p>
<p>Some of the concepts in programming and you might not understand how important they are but keep with it, as you start using them you will see why they are important.</p>
<p><strong><em>What is a program?</em></strong></p>
<p><strong></strong>A program is a set of instructions to the Raspberry Pi to get it to do something. The program must be written in a language &#8211; a language which has certain rules as to how it is written. The language we are going to use is called Python.</p>
<p>All we need to know at the moment is that the Raspberry Pi understands Python. This is just the same as you or I can understand English. So if somebody gives us some instructions in English we can carry them out. Likewise with the Raspberry Pi if it is given  some instructions in Python it can understand them and carry them out. This happens when the program is run.</p>
<p>It is also important to realise that once the program has been run it will try and carry out every instruction, one line after another in the order you had written them down in the program. It will only stop when it has no more instructions to carry out.</p>
<p>Much like speaking a language, when you write a programming language there are certain building blocks that you use which let you do powerful things with a program and also help you organise it. The first of these building blocks we will introduce are called constants.</p>
<p><em><strong>Constants and how they can help</strong></em></p>
<p>As you may have seen from the previous bit of code that got the Pi-Car going, it was actually quite difficult to understand. The first thing that can help us with this are called constants.</p>
<p>The best way of explaining a constant is by adding them to the code we created in <a title="Pi-Cars and Python – Driving Lesson #1" href="http://pi-cars.com/2013/01/10/pi-cars-and-python-driving-lesson-1/">driving lesson #1.</a></p>
<ul>
<li><span style="line-height:16px;"><strong>Lets get driving&#8230;</strong><a name="letsgetdriving"></a><br />
</span></li>
</ul>
<p><em><strong>Adding constants</strong></em></p>
<p>Here is the code created in the first driving lesson:</p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(12,GPIO.OUT)

GPIO.output(12,1)

time.sleep(3)

GPIO.output(12,0)
</pre>
<p>Chances are you probably cannot remember what all of this means and what it makes the Pi-Car do, so lets add some constants to make it easier to understand. Change your code so it looks like below:</p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO

ON = 1
OFF = 0

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(12,GPIO.OUT)

GPIO.output(12,ON)

time.sleep(3)

GPIO.output(12,OFF)
</pre>
<p>With the changes you made above it is a good idea to run the program again to check that you have it right. As before, if connected to the Pi-Car it should move forwards, wait for 3 seconds and the stop. <strong>If you cannot remember how you actually write Python code on the Raspberry Pi and then run it <a title="Writing Python in the Raspberry Pi" href="http://pi-cars.com/2013/01/10/pi-cars-and-python-driving-lesson-1#pythoneditor">click here</a>.</strong></p>
<p>Lets have a look at what we added in the program above. Adding the lines:</p>
<pre class="brush: python; title: ; notranslate">
ON = 1
OFF = 0
</pre>
<p>means that you are instructing the program to create a constant called ON and another constant called OFF. The &#8216;=&#8217; sign is used to give each constant a value. In programming you have to have it this way round with the name on the left hand-side followed by the &#8216;=&#8217; symbol and and the value you want to set it to on the right hand-side.</p>
<p>Once your constants are created you can then use them later in the same program:</p>
<pre class="brush: python; title: ; notranslate">
GPIO.output(12,ON)

time.sleep(3)

GPIO.output(12,OFF)
</pre>
<p>This makes it much easier to understand, you can quickly see that you are turning GPIO pin 12 on and off (which in turn moves the Pi-Car forwards and then stops it moving forwards).</p>
<p><em><strong>Adding more constants</strong></em></p>
<p>It may not appear that important to be able to do this at the moment but when your programs get bigger it is a great help to be able to understand what is happening. We can see this in action by adding more instructions to the program to move the Pi-Car in other directions. We do this by turning on and off other GPIO pins.</p>
<p>In a Pi-Car the way the GPIO pins result in a particular command to the Pi-Car is as follows:</p>
<ul>
<li>GPIO pin 11 – backwards</li>
<li>GPIO pin 12 – forwards</li>
<li>GPIO pin 13 – left</li>
<li>GPIO pin 15 – right</li>
</ul>
<p>Rather than always having to put the GPIO pin number into the code, these are perfect candidates to make into constants. Once they are we do not need to keep on remembering that 13 is left every time we want to use it, or that 12 is forwards. It makes our life that bit easier which is what engineering is all about!</p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO
ON = 1
OFF = 0
BACKWARDS = 11
FORWARDS = 12
LEFT = 13
RIGHT = 15

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(FORWARDS,GPIO.OUT)
GPIO.output(FORWARDS,ON)
time.sleep(3)
GPIO.output(FORWARDS,OFF)
</pre>
<p>Again with the changes you have made above run the code again to check that it still works. Your Pi-Car should still just move forwards, wait for 3 seconds and stop moving forwards.</p>
<p>As we did before we create our constants with the names on the left, following by an &#8216;=&#8217; symbol and then the value we want to give it:</p>
<pre class="brush: python; title: ; notranslate">
BACKWARDS = 11
FORWARDS = 12
LEFT = 13
RIGHT = 15
</pre>
<p>With the constants created we can then use them later in the program instead of writing the number:</p>
<pre class="brush: python; title: ; notranslate">
GPIO.setup(FORWARDS,GPIO.OUT)
GPIO.output(FORWARDS,ON)
time.sleep(3)
GPIO.output(FORWARDS,OFF)
</pre>
<p>This helps us when we try and understand the program and also it means we will not make an error typing the number in.</p>
<p>With our constants defined it is now quite easy to write the instructions that make the Pi-Car goes in other directions:</p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO
ON = 1
OFF = 0
FORWARDS = 12
BACKWARDS = 11
LEFT = 13
RIGHT = 15

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(FORWARDS,GPIO.OUT)
GPIO.setup(BACKWARDS,GPIO.OUT)
GPIO.setup(LEFT,GPIO.OUT)
GPIO.setup(RIGHT,GPIO.OUT)

GPIO.output(FORWARDS,ON)
time.sleep(3)
GPIO.output(FORWARDS,OFF)

GPIO.output(BACKWARDS,ON)
time.sleep(3)
GPIO.output(BACKWARDS,OFF)

GPIO.output(LEFT,ON)
time.sleep(3)
GPIO.output(LEFT,OFF)

GPIO.output(RIGHT,ON)
time.sleep(3)
GPIO.output(RIGHT,OFF)
</pre>
<p>It is now quite easy to understand what the code above is trying to do, so run the Python code again and check that your Pi-Car does what you asked it to.</p>
<p><em><strong>Moving the Pi-Car left and right</strong></em></p>
<p>So we can now activate all the functions of the Pi-Car from the Raspberry Pi but it is still quite basic. For instance you will have noticed that when you ran the program above the Pi-Car wheels just turned left and then right rather than moving left and right because forwards was not on.</p>
<p>In order to make the Pi-Car actually move left for example you will need to do the following:</p>
<pre class="brush: python; title: ; notranslate">
GPIO.output(LEFT,ON)
GPIO.output(FORWARDS,ON)
time.sleep(3)
GPIO.output(LEFT,OFF)
GPIO.output(FORWARDS,OFF)
</pre>
<p><strong><em>Getting the program to talk to us</em></strong></p>
<p>You may have found that when you tried to do run the programs above they did not work as you hoped. You may also not always want to chase after your Pi-Car all the time as you are writing your program and want another way of knowing what it is doing.</p>
<p>So how can we find this out? The best way is to have the Python program tell you what it is doing. The way to do this with Python is to use the print statement. The print statement could say</p>
<pre class="brush: python; title: ; notranslate">
print (&quot;moving forwards&quot;)
</pre>
<p>Or:</p>
<pre class="brush: python; title: ; notranslate">
print (&quot;moving backwards&quot;)
</pre>
<p>We simply need to add this instruction to the program and Python will understand it and print to the screen where Python is running.</p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO
ON = 1
OFF = 0
FORWARDS=12
BACKWARDS=11
LEFT=13
RIGHT=15

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(FORWARDS,GPIO.OUT)
GPIO.setup(BACKWARDS,GPIO.OUT)
GPIO.setup(LEFT,GPIO.OUT)
GPIO.setup(RIGHT,GPIO.OUT)

GPIO.output(FORWARDS,ON)
print (&quot;Moving forwards&quot;)
time.sleep(3)
GPIO.output(FORWARDS,OFF)

GPIO.output(BACKWARDS,ON)
print (&quot;Moving backwards&quot;)
time.sleep(3)
GPIO.output(BACKWARDS,OFF)

GPIO.output(LEFT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving left&quot;)
time.sleep(3)
GPIO.output(LEFT,OFF)
GPIO.output(FORWARDS,OFF)

GPIO.output(RIGHT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving right&quot;)
time.sleep(3)
GPIO.output(RIGHT,OFF)
GPIO.output(FORWARDS,OFF)
</pre>
<p>Try and run the program and you should see the text print to screen at the same time as your Pi-Car moves around. All you have to remember is to put what you want to print inside brackets and between the speech marks &#8211; &#8221; &#8220;.</p>
<p>Another thing you can do is print out the value of the constants you created. For example maybe you got your GPIO pin numbers muddled up. You would be able to find this out by printing out the value of the constants you are using for FORWARDS, BACKWARDS and the others:</p>
<pre class="brush: python; title: ; notranslate">
import time, RPi.GPIO as GPIO
ON = 1
OFF = 0
FORWARDS=12
BACKWARDS=11
LEFT=13
RIGHT=15

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(FORWARDS,GPIO.OUT)
GPIO.setup(BACKWARDS,GPIO.OUT)
GPIO.setup(LEFT,GPIO.OUT)
GPIO.setup(RIGHT,GPIO.OUT)

GPIO.output(FORWARDS,ON)
print (&quot;Moving forwards after turning on forwards GPIO pin no = &quot;, FORWARDS)
time.sleep(3)
GPIO.output(FORWARDS,OFF)
GPIO.output(BACKWARDS,ON)
print (&quot;Moving backwards after turning on backwards GPIO pin no = &quot;,BACKWARDS)
time.sleep(3)
GPIO.output(BACKWARDS,OFF)

GPIO.output(LEFT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving left after turning on left GPIO pin no = &quot;,LEFT)
time.sleep(3)
GPIO.output(LEFT,OFF)
GPIO.output(FORWARDS,OFF)

GPIO.output(RIGHT,ON)
GPIO.output(FORWARDS,ON)
print (&quot;Moving right after turning on right GPIO pin no = &quot;,RIGHT)
time.sleep(3)
GPIO.output(RIGHT,OFF)
GPIO.output(FORWARDS,OFF)
</pre>
<p>When you run the program this time you should see the GPIO pin numbers print out. Notice here that you put the constant name outside of the speech marks:</p>
<pre class="brush: python; title: ; notranslate">
print (&quot;Moving right after turning on right GPIO pin no = &quot;,RIGHT)
</pre>
<p>If you put it inside the speech marks the Raspberry Pi would think you wanted to print out the word RIGHT. Because you put the &#8216;,&#8217; symbol this tells the Raspberry Pi you want to add it to the end of the string.</p>
<ul>
<li><span style="line-height:16px;"><strong>Driving Lesson review</strong><br />
</span></li>
</ul>
<p><span style="font-size:medium;"><span style="line-height:24px;">Congratulations you made it through, hopefully you did actually crash your Pi-Car a few times as it means you managed to get it moving. In this lesson you leant two main things:</span></span></p>
<p><strong style="font-size:16px;">Constants:</strong></p>
<p><em><strong>How to use</strong></em></p>
<p><span style="font-size:medium;">1. Put the name on the left and the value on the right, choose a suitable name:</span></p>
<pre class="brush: python; title: ; notranslate">
ON = 1
</pre>
<p><span style="font-size:16px;">2. Create them before you can use them in your program.</span></p>
<p><span style="font-size:medium;"><span style="line-height:24px;"><em><strong>Why do they help?</strong></em><br />
</span></span></p>
<p>1. It makes it easier to read your program.</p>
<p>2. If you use the same value in lots of different places it will make sure that it always is the same. Also if you want to change it you can just change it in one place.</p>
<ul>
<li><strong>Print statement:</strong></li>
</ul>
<p><em><strong>How to use</strong></em></p>
<p>1. Add the word print followed by what you want to print out in speech marks:</p>
<pre class="brush: python; title: ; notranslate">
print (&quot;moving forwards&quot;)
</pre>
<p>2. If you want to print out the value of a constant add the name of the constant and make sure it is <strong>not</strong> inside the speech marks:</p>
<pre class="brush: python; title: ; notranslate">
print (&quot;Moving right after turning on right GPIO pin no = &quot;,RIGHT)
</pre>
<ul>
<li><span style="line-height:16px;"><strong>Gotcha&#8217;s</strong><br />
</span></li>
</ul>
<p><span style="font-size:medium;"><span style="line-height:24px;">In any engineering things rarely work first time so don&#8217;t worry. Hopefully the list below will help. If not email us at info@pi-cars.com and leave a comment providing your code and what you tried to do, the solution will be obvious as soon as you see it!</span></span></p>
<ol>
<li><span style="line-height:16px;"><strong>I keep on getting invalid syntax after I try and run the code?</strong> <em>The code listed above will run by typing sudo python filename in the command prompt and also when run from IDLE3 but from IDLE it will complain of a syntax error. This is because of IDLE wants the print statement without the brackets, like print &#8220;message&#8221; rather than print (&#8220;message&#8221;)</em></span></li>
<li><strong>How to I edit and run the code?</strong> <em>You can write Python code into any text editor, you can open up Leaf that comes with the Raspberry Pi, or you can open a terminal and type sudo nano which will open a text editor. Our tutorials use IDLE3 as this provides tips on syntax and you can also run it from there. If you use a text editor you will have to run the code by opening a terminal and typing sudo python filename.py</em></li>
<li><strong>It tells me to try root what is that!?</strong> <em>Accessing the GPIO pins currently needs you to have a bit of extra power than a normal user. To do this if you run your Python file from the command line you will need to type &#8216;sudo python filename.py&#8217; rather than just python. The sudo word gives you the extra power. If you are using IDLE3 you need to open a terminal and type &#8216;sudo idle3&#8242; rather than double clicking on it. A bit of a pain which will be fixed soon!</em></li>
</ol>
<p><a title="Variables and while loops – Driving Lesson #3" href="http://pi-cars.com/2013/03/01/variables-and-while-loops-driving-lesson-3/">Next -&gt; Driving Lesson #3 Variables</a></p>
<p><a title="Pi-Cars and Python – Driving Lesson #1" href="http://pi-cars.com/2013/01/10/pi-cars-and-python-driving-lesson-1/">Previous -&gt; Driving Lesson #1 Pi-Cars and Python</a></p>
<h3>PDF Version</h3>
<p>PDF version of this article - <a href="http://barnabypaulkent.files.wordpress.com/2013/04/introduction-to-python-constants-and-print-statements-e28093-driving-lesson-2-_-pi-cars.pdf">Introduction to Python, constants and print statements – Driving Lesson #2 _ Pi-Cars</a><a href="http://barnabypaulkent.files.wordpress.com/2013/04/pi-cars-and-python-e28093-driving-lesson-1-_-pi-cars.pdf"><br />
</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/barnabypaulkent.wordpress.com/782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/barnabypaulkent.wordpress.com/782/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=782&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pi-cars.com/2013/02/15/introduction-to-programming/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/bf149e636959abaa09b15d619258b985?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barnabypaulkent</media:title>
		</media:content>
	</item>
		<item>
		<title>Pi-Cars Factory &#8211; Tool Kit</title>
		<link>http://pi-cars.com/2013/01/24/pi-cars-factory-beginners-tool-kit/</link>
		<comments>http://pi-cars.com/2013/01/24/pi-cars-factory-beginners-tool-kit/#comments</comments>
		<pubDate>Thu, 24 Jan 2013 00:02:15 +0000</pubDate>
		<dc:creator>Barnaby Kent</dc:creator>
				<category><![CDATA[Under the bonnet]]></category>
		<category><![CDATA[factory]]></category>
		<category><![CDATA[pi-car]]></category>
		<category><![CDATA[soldering]]></category>
		<category><![CDATA[Tool Kit]]></category>
		<category><![CDATA[under the bonnet]]></category>

		<guid isPermaLink="false">http://pi-cars.com/?p=580</guid>
		<description><![CDATA[Welcome to the factory: Welcome to where you will learn how to build a Pi-Car, we call it the Pi-Cars Factory. We hope that this page contains all you need to know as well as linking to resources to let &#8230; <a href="http://pi-cars.com/2013/01/24/pi-cars-factory-beginners-tool-kit/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=580&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><strong>Welcome to the factory:</strong></p>
<p><strong></strong>Welcome to where you will learn how to build a Pi-Car, we call it the Pi-Cars Factory. We hope that this page contains all you need to know as well as linking to resources to let you find out more about how it all works.</p>
<p>We hope the instructions and photos below are clear enough but if not please leave a comment or email us at info@pi-cars.com Remember you can click on all the photos in order to see a close up.</p>
<p>In the film Matt is teaching Emily how to build a Pi-Car. Before this Emily had never done any soldering or electronics so hopefully you will be successful as well &#8211; even if you have never done anything like it before.</p>
<p><strong>Health and Safety awareness:</strong></p>
<p>Please be aware that a small amount of soldering is required for making a Pi-Car and soldering can be dangerous because of the heat and fumes. If in doubt always consult an adult with some knowledge of soldering and make sure you work in a well ventilated area.</p>
<p>Also remember that the Tool Kit and it&#8217;s parts contain small parts which may pose a choking hazard. Keep away from children under three years old.</p>
<p>Finally when using the screwdriver to take the back off the controller take care and follow the instructions below &#8211; it comes off quite easily if you press in the correct place. Ensure that the screwdriver does not slip.</p>
<p><strong>Factory tour:</strong></p>
<p>To make your Pi-Car you obviously need a factory and all the relevant bits. What you need is listed below together with where you can get them from:</p>
<ul>
<li>Pi-Car Tool Kit &#8211; you can reserve this by <a title="Reserve Pi-Car Tool Kit" href="http://pi-cars.com/order-pi-car-tool-kit/">clicking here</a></li>
<li>Compatible radio controlled car &#8211; you can reserve one of these by <a title="Reserve Pi-Car Tool Kit" href="http://pi-cars.com/order-pi-car-tool-kit/">clicking here</a></li>
<li>Soldering Iron</li>
<li>Flat-head screwdriver and smaller Philips screwdriver</li>
<li>Wire trimmers</li>
<li>Multimeter &#8211; optional</li>
<li>A factory to work in! You do need some space to work in &#8211; a table top is enough and as you will be soldering it is best to have an area close to a window so you can get a draft to blow away the fumes.</li>
</ul>
<p><strong>Preparing your Radio Controlled car for transformation into a Pi-Car:</strong></p>
<p><strong><span style="line-height:16px;">Selecting and un-boxing the car</span></strong></p>
<p>There are a number of different radio controlled cars that can be transformed into Pi-Cars. We have converted quite a number of different types! We will sell a variety of different models that we know work in the Pi-Cars shop &#8211; click here to <a title="Reserve Pi-Car Tool Kit" href="http://pi-cars.com/order-pi-car-tool-kit/">reserve one</a> or click here to see them in the Pi-Cars showroom.</p>
<p>The instructions below have been completed using a New Bright Model 1825. If you use a different model or manufacturer the instructions and photos that focus on the controller will be slightly different. If you convert a car that is not in our Showroom send us a video or the details and we&#8217;ll add it!</p>
<p>With your car selected un-box it and fit the batteries &#8211; for this car you will need 2 AA batteries to go into the controller and 3 AA batteries to go into your radio controlled car.</p>
<p><strong>Take the controller to bits</strong></p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/YZyUbxXoE1w?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>You may want to have a play with the car first before you start disconnecting it! Once you are done playing take the battery cover off and the batteries out and unscrew the back from the controller.</p>
<div id="attachment_594" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/back-of-controller-with-screw-to-remove.jpg"><img class="size-medium wp-image-594" alt="Back of controller with screw to remove" src="http://barnabypaulkent.files.wordpress.com/2013/01/back-of-controller-with-screw-to-remove.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Remove the highlighted screw to remove the cover.</p></div>
<p>Next peel off the CE label (bear in mind this does invalidate the warranty of the car at this point). With the label removed you can now un-clip the four different clips &#8211; two on the top and two on the bottom. You can do this with a flat-head screwdriver easing it open.</p>
<p>On the two clips on the top push in the flat-head screwdriver, push it in and then lever it down:</p>
<div id="attachment_690" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/top-of-controller-with-screwdriver-to-disconnect.jpg"><img class="size-medium wp-image-690" alt="Top of Controller with screwdriver to disconnect" src="http://barnabypaulkent.files.wordpress.com/2013/01/top-of-controller-with-screwdriver-to-disconnect.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Top of controller with screwdriver about to be pressed in.</p></div>
<div id="attachment_691" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/top-of-controller-with-screwdriver-pushed-in-to-disconnect.jpg"><img class="size-medium wp-image-691" alt="Top of Controller with screwdriver pushed in to disconnect" src="http://barnabypaulkent.files.wordpress.com/2013/01/top-of-controller-with-screwdriver-pushed-in-to-disconnect.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Top of controller with screwdriver pressed in before levering down.</p></div>
<div id="attachment_692" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/top-of-controller-with-screwdriver-levered-up.jpg"><img class="size-medium wp-image-692" alt="Top of Controller with screwdriver levered up" src="http://barnabypaulkent.files.wordpress.com/2013/01/top-of-controller-with-screwdriver-levered-up.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Top of controller with screwdriver levered down in order to disconnect.</p></div>
<p>With the top two unclipped you can now un-clip the bottom clips as well in the same manner:</p>
<div id="attachment_694" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/bottom-of-controller-with-screwdriver.jpg"><img class="size-medium wp-image-694" alt="Bottom of controller with screwdriver" src="http://barnabypaulkent.files.wordpress.com/2013/01/bottom-of-controller-with-screwdriver.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Bottom of controller with screwdriver to disconnect.</p></div>
<p>You now need to take the levers out &#8211; you can do this by moving out one side of the lever followed by the other. They may need to be un-clicked out:</p>
<div id="attachment_596" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-test-points1.jpg"><img class="size-medium wp-image-596" alt="Controller with levers removed" src="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-test-points1.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Controller with the forwards / back and left / right levers removed.</p></div>
<p><strong>Test and understand the car</strong></p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/2o2vK-PByGc?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>At this point you can test the car with a multimeter which will help you understand how we are going to modify the Radio controlled car to turn it into a Pi-Car. You can jump this section if you wish but if you do have access to a multimeter we do recommend that you complete it.</p>
<p>Firstly check that the buttons still work by pressing the small black micro switches with your fingers. When you press them the car should move as if moving the levers:</p>
<div id="attachment_597" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-switches-highlighted.jpg"><img class="size-medium wp-image-597" alt="Controller with switches highlighted" src="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-switches-highlighted.jpg?w=300&#038;h=264" width="300" height="264" /></a><p class="wp-caption-text">Controller with the switches highlighted that move the car forwards, backwards, left and right.</p></div>
<p>Turn the multimeter to 20 volts DC by moving the dial:</p>
<div id="attachment_598" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/multimeter-set-to-20-volts-ready-to-test.jpg"><img class="size-medium wp-image-598" alt="Multimeter set to 20 volts ready to test" src="http://barnabypaulkent.files.wordpress.com/2013/01/multimeter-set-to-20-volts-ready-to-test.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">You can run some tests on the controller with a multimeter set to 20 volts as above.</p></div>
<p>Put the black probe onto the silver test point marked TP202 highlighted in the diagram below. This corresponds to zero volts:</p>
<div id="attachment_601" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-test-point-202-highlighted.jpg"><img class=" wp-image-601  " alt="Controller with test point 202 highlighted" src="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-test-point-202-highlighted.jpg?w=300&#038;h=151" width="300" height="151" /></a><p class="wp-caption-text">Test point 202 highlighted on the controller &#8211; this is zero vaults &#8211; the black probe from the multimeter should be placed on this test point.</p></div>
<p>The red probe should go on the silver test point marked TP81 highlighted in the diagram below which traces through to backwards:</p>
<div id="attachment_603" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-test-point-80-highlighted.jpg"><img class="size-medium wp-image-603" alt="Controller with test point 80 highlighted" src="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-test-point-80-highlighted.jpg?w=300&#038;h=124" width="300" height="124" /></a><p class="wp-caption-text">The red probe from the multimeter should go on test point 80 (highlighted) which relates to backwards.</p></div>
<p>When you have the probes on these test points you should see on the multimeter that you have a reading of 3 volts. If you then press the backwards switch the voltage should decrease to zero this is because one side of the switch is being pulled down to zero volts.</p>
<p><strong>Transforming the Controller:</strong></p>
<p><strong>Soldering with the controller</strong></p>
<p>We now need to connect wires onto the test points which will be connected via the electronics we&#8217;ll construct from our Tool Kit onto the Raspberry Pi GPIO pins.</p>
<p>In order to make it easier to connect these wires to the controller, firstly the test points on the controller need to be enlarged. This is your first chance to use your soldering iron! For the Raspberry Pi guide to soldering <a title="Raspberry Pi Soldering is Easy" href="http://www.raspberrypi.org/archives/1494" target="_blank">click here</a>. For the Instructables guide<a title="Instructables guide to solder" href="http://www.instructables.com/id/How-to-solder/" target="_blank"> click here</a> for the Make guide to solder <a title="Make guide to soldering" href="http://blog.makezine.com/2011/01/06/skill-set-soldering/" target="_blank">click here.</a></p>
<p>Heat up your soldering iron place the flat end of the soldering iron onto the test point. After around  a second the test point will melt. You can then place a piece of solder onto the soldering iron. This will create a bigger &#8216;bubble&#8217; of solder onto the test point.</p>
<div id="attachment_606" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/expanding-a-test-point-with-the-soldering-iron.jpg"><img class="size-medium wp-image-606" alt="Expanding a test point with the Soldering iron" src="http://barnabypaulkent.files.wordpress.com/2013/01/expanding-a-test-point-with-the-soldering-iron.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Using a soldering iron and some solder to expand a test point.</p></div>
<p>Each of the test points highlighted below need to be enlarged. These are test points</p>
<ul>
<li>TP202 (0 volts)</li>
<li>TP81 (backwards)</li>
<li>TP80 (forwards)</li>
<li>TP82 (left)</li>
<li>TP83 (right)</li>
</ul>
<div id="attachment_607" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-all-test-points-highlighted.jpg"><img class="size-medium wp-image-607" alt="Controller with all test points highlighted" src="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-all-test-points-highlighted.jpg?w=300&#038;h=210" width="300" height="210" /></a><p class="wp-caption-text">All the test points highlighted needs to be expanded.</p></div>
<p><strong>Tinning and feeding through wires </strong></p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/CJ8B8BDVL74?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>Select the wires shown in the picture below. On one end they have a black connector (this is called a female) and on the other end they just have a bare wire coming out.</p>
<div id="attachment_665" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/female-to-stripped-wire.jpg"><img class="size-medium wp-image-665" alt="Female to stripped wire" src="http://barnabypaulkent.files.wordpress.com/2013/01/female-to-stripped-wire.jpg?w=300&#038;h=168" width="300" height="168" /></a><p class="wp-caption-text">Set of 5 cables female at one end and stripped wire at the other.</p></div>
<p>Before feeding through the wires it is a good idea to add some solder to the wires. This is called &#8216;tinning the wires&#8217; and means they get a much better connection when they are soldered on.</p>
<p>Before you can tin them you need to make sure all the strands of wire are nicely compacted to get a good connection. You can do this by simply twisting the strands as shown in the photo below:</p>
<div id="attachment_695" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/two-wires-twisted-and-ready-two-still-not-ready.jpg"><img class="size-medium wp-image-695" alt="Two wires twisted and ready two still not ready" src="http://barnabypaulkent.files.wordpress.com/2013/01/two-wires-twisted-and-ready-two-still-not-ready.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Two of the wires have been twisted to provide a nice solid wire, the remaining three show how they may look out of the pack.</p></div>
<p>To tin the wire it is easiest to rest the wires on something so that they are suspended. One at a time place the soldering iron underneath the wire and touch it onto the wire to heat it up. Touch the solder onto the wire and then move it along the wire to spread some solder along the length of the wire.</p>
<div id="attachment_697" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/before-tinning-the-wire-with-solder-ready.jpg"><img class="size-medium wp-image-697" alt="Before tinning the wire with solder ready" src="http://barnabypaulkent.files.wordpress.com/2013/01/before-tinning-the-wire-with-solder-ready.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Setting the wires up to tin them with the soldering iron and some solder.</p></div>
<div id="attachment_699" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/tinning-the-green-wire-with-solder.jpg"><img class="size-medium wp-image-699" alt="Tinning the green wire with solder" src="http://barnabypaulkent.files.wordpress.com/2013/01/tinning-the-green-wire-with-solder.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Beginning to tin the wire with the solder and soldering iron.</p></div>
<div id="attachment_698" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/tinning-the-green-wire-with-solder-further-on.jpg"><img class="size-medium wp-image-698" alt="Tinning the green wire with solder further on" src="http://barnabypaulkent.files.wordpress.com/2013/01/tinning-the-green-wire-with-solder-further-on.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Almost completed the tinning of the wire.</p></div>
<p>You don&#8217;t have to do this but it will make it much easier to connect the wire to the controller test points later!</p>
<p>Feed through the wires through the existing hole in the back of the controller, they need to be fed through over the back of the board. This can be done all at once:</p>
<div id="attachment_667" class="wp-caption alignnone" style="width: 178px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/feeding-cables-through-controller.jpg"><img class="size-medium wp-image-667" alt="Feeding cables through controller" src="http://barnabypaulkent.files.wordpress.com/2013/01/feeding-cables-through-controller.jpg?w=168&#038;h=300" width="168" height="300" /></a><p class="wp-caption-text">The bare wire ends can be fed through the existing hole at the back of the controller.</p></div>
<p>You can then pull the wires through ready for soldering onto the test points of the controller as shown below:</p>
<div id="attachment_668" class="wp-caption alignnone" style="width: 178px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/wires-through-ready-to-connect-to-test-points.jpg"><img class="size-medium wp-image-668" alt="Wires through ready to connect to test points" src="http://barnabypaulkent.files.wordpress.com/2013/01/wires-through-ready-to-connect-to-test-points.jpg?w=168&#038;h=300" width="168" height="300" /></a><p class="wp-caption-text">Pull the bare ends of the wires through so that they are ready for soldering onto the board.</p></div>
<p>You are ready for connecting up to the test points.</p>
<p><strong>Soldering the wires onto the test points on the controller</strong></p>
<p>You can now solder the wires to the controller. The different colour wires should be connected as follows:</p>
<ul>
<li><span style="line-height:16px;">Purple wire &#8211; TP202 (0 volts)</span></li>
<li>Blue wire &#8211; TP81 (backwards)</li>
<li>Green wire &#8211; TP80 (forwards)</li>
<li>Yellow wire &#8211; TP82 (left)</li>
<li>Orange wire &#8211; TP83 (right)</li>
</ul>
<p>Before you connect on the wires you probably need to trim them down slightly so they fit nicely. You may have burnt back some of the sheath of the wire when you were soldering so just trim the wire back until there is just less than half a centimetre left:</p>
<div id="attachment_702" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/snipping-the-wires-before-connection-to-the-controller.jpg"><img class="size-medium wp-image-702" alt="Snipping the wires before connection to the controller" src="http://barnabypaulkent.files.wordpress.com/2013/01/snipping-the-wires-before-connection-to-the-controller.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Snip back the wire so there is just less than half a centimetre left.</p></div>
<p>Solder each wire one at a time by placing the soldering iron onto the test point which should melt after about a second. When it does place the wire into the melted solder and remove the  soldering iron.</p>
<div id="attachment_701" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/connecting-the-wires-to-the-controller.jpg"><img class="size-medium wp-image-701" alt="Connecting the wires to the controller" src="http://barnabypaulkent.files.wordpress.com/2013/01/connecting-the-wires-to-the-controller.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Soldering the wires onto the controller.</p></div>
<div id="attachment_622" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-wires-connected.jpg"><img class="size-medium wp-image-622" alt="Controller with wires connected" src="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-wires-connected.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Controller with wires connected onto test points.</p></div>
<p><strong>Creating the Electronics:</strong></p>
<p><strong>Introducing the breadboard</strong></p>
<p>Take the white rectangular object that came with your Pi-Cars Tool Kit, this is the Breadboard.</p>
<div id="attachment_624" class="wp-caption alignnone" style="width: 234px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-closer-up-e1358372812985.jpg"><img class="size-medium wp-image-624" alt="Breadboard closer up" src="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-closer-up-e1358372812985.jpg?w=224&#038;h=300" width="224" height="300" /></a><p class="wp-caption-text">Close up of breadboard from Pi-Cars Tool Kit</p></div>
<p>The breadboard is used for making electronics circuits. The video provides a further explanation of how the breadboard works and how you can use your multimeter to understand it:</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/02KcjJoR66U?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>Our upcoming research and development section will also provide more detail on exactly how a breadboard works.</p>
<p><strong>Putting the components on the breadboard</strong></p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/s8aRG_yjH0I?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>We are now ready to start adding components to the breadboard. The first items to add are the Field-effect Transistors (FETS). There are three legs for each of these FETS and each leg should go into a hole in a different row. It is important to get the FET the right way round. The circular side should be pointed towards the left edge of the breadboard as shown below (click on the photo to increase the size):</p>
<div id="attachment_625" class="wp-caption alignnone" style="width: 234px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-one-fet-added-e1358372843362.jpg"><img class="size-medium wp-image-625" alt="Breadboard with one FET added" src="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-one-fet-added-e1358372843362.jpg?w=224&#038;h=300" width="224" height="300" /></a><p class="wp-caption-text">The FET should be added as per the above diagram &#8211; note that it needs to be the correct way round.</p></div>
<p>Each FET has three legs called the drain, gate and the source. These should go into three holes next to each other</p>
<ul>
<li>Drain into column A row 1</li>
<li>Gate into column A row 2</li>
<li>Source into column A row 3</li>
</ul>
<p>As shown in the photo below:</p>
<div id="attachment_626" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-one-fet-added-close-up.jpg"><img class="size-medium wp-image-626" alt="Breadboard with one FET added close up" src="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-one-fet-added-close-up.jpg?w=300&#038;h=247" width="300" height="247" /></a><p class="wp-caption-text">FET legs going into the different rows on the breadboard.</p></div>
<p>Add three more FETS to the breadboard making them evenly spaced along the breadboard. We would suggest the following holes for the breadboard:</p>
<ul>
<li>Second FET &#8211; leg 1 &#8211; row 10, leg 2 &#8211; row 11, leg 3 &#8211; row 12</li>
<li>Third FET &#8211; leg 1 &#8211; row 19, leg 2 row 20, leg 3 row 21</li>
<li>Fourth FET &#8211; leg 1 &#8211; row 28, leg 2 row 29, leg 3 row 30</li>
</ul>
<p><span style="font-size:16px;">As shown below:</span></p>
<div id="attachment_627" class="wp-caption alignnone" style="width: 234px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-all-fets-added-e1358372669518.jpg"><img class="size-medium wp-image-627" alt="Breadboard with all FETS added" src="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-all-fets-added-e1358372669518.jpg?w=224&#038;h=300" width="224" height="300" /></a><p class="wp-caption-text">Breadboard with all four FETs added.</p></div>
<p>The next item to add is the resistor onto the board. One of these should be put into column C of the breadboard so that there is one spare hole between the resistor and the FET. Each resistor only has two legs these should be in line with the gate and the source legs of the FET. Don&#8217;t worry you cannot get the resistor the wrong way round.</p>
<p>So the first leg of the first resistor should go into column C row 2. You will then need to bend the resistor to position the next leg into column C row 3 as shown in the diagram below:</p>
<div id="attachment_631" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-all-fets-and-resistor-close-up.jpg"><img class="size-medium wp-image-631" alt="Breadboard with all FETS and resistor close up" src="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-all-fets-and-resistor-close-up.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Add the resistor onto the breadboard, one leg should go into column C row 2 and the other leg into column C row 3.</p></div>
<div id="attachment_632" class="wp-caption alignnone" style="width: 234px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-fets-added-and-one-resistor-added-e1358376629151.jpg"><img class="size-medium wp-image-632" alt="Breadboard with FETS added and one resistor added" src="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-fets-added-and-one-resistor-added-e1358376629151.jpg?w=224&#038;h=300" width="224" height="300" /></a><p class="wp-caption-text">Breadboard with FETs and one resistor added.</p></div>
<p>The remaining three resistors should then be added to the breadboard. These should be placed as the first resistor all going into column C. If you put your FETs into the rows we detailed earlier you should put your resistors as follows:</p>
<ul>
<li>First resistor legs into column C rows 2 and 3.</li>
<li><span style="line-height:16px;">Second resistor legs into column C rows 11 and 12.</span></li>
<li><span style="line-height:16px;">Third resistor legs into column C rows 20 and 21.</span></li>
<li><span style="line-height:16px;">Fourth resistor legs into column C rows 29 and 30.</span></li>
</ul>
<div id="attachment_635" class="wp-caption alignnone" style="width: 234px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-all-fets-and-resistors-added.jpg"><img class="size-medium wp-image-635" alt="Breadboard with all FETS and resistors added" src="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-all-fets-and-resistors-added-e1358377073794.jpg?w=224&#038;h=300" width="224" height="300" /></a><p class="wp-caption-text">Breadboard with all resistors added in addition to the FETs</p></div>
<p>Next you need to take the male to male jumper leads onto the breadboard. The four male to male leads are shown in the photo below. These are the collection of four wires which may be black, grey, white or brown:</p>
<div id="attachment_689" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/male-to-male-cables-for-breadboard-interconnection.jpg"><img class="size-medium wp-image-689" alt="Male to male cables for breadboard interconnection" src="http://barnabypaulkent.files.wordpress.com/2013/01/male-to-male-cables-for-breadboard-interconnection.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Male to male cables of the same colour for breadboard interconnections</p></div>
<p>Firstly you need to press one end of the jumper lead into the row in between the FET and the resistor. It should go into the row with the second leg of the resistor and the third leg (the source) of the FET. If you followed the numbering above this would be in column B row 3:</p>
<div id="attachment_637" class="wp-caption alignnone" style="width: 234px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/jumper-cable-inserted-between-the-fet-and-resistor.jpg"><img class="size-medium wp-image-637" alt="Jumper cable inserted between the FET and resistor" src="http://barnabypaulkent.files.wordpress.com/2013/01/jumper-cable-inserted-between-the-fet-and-resistor.jpg?w=224&#038;h=300" width="224" height="300" /></a><p class="wp-caption-text">Male jumper cable inserted into column between FET and resistor.</p></div>
<p>The other end of the cable needs to go to a column where all zero volts cables should go. Here we are allocating this as the far right column marked with a minus sign so the cable should be pressed into that column.</p>
<p>The cable can in fact go into any row in that column but for neatness sake we will put it into the same row as the other end.</p>
<div id="attachment_638" class="wp-caption alignnone" style="width: 234px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/jumper-cable-other-end-connected-to-the-source.jpg"><img class="size-medium wp-image-638" alt="Jumper cable other end connected to the source" src="http://barnabypaulkent.files.wordpress.com/2013/01/jumper-cable-other-end-connected-to-the-source.jpg?w=224&#038;h=300" width="224" height="300" /></a><p class="wp-caption-text">Jumper cable connected at both ends, one to ground or zero volts and the other to the resistor and FET.</p></div>
<p>You can now put the remaining three cables into place. As with the first cable put one end of the lead into column B row 3 between the second leg of the resistor and the third leg of the FET. If you have followed the numbering on the breadboard so far it will mean:</p>
<ul>
<li>First jumper lead into column B row 3</li>
<li>Second jumper lead into column B row 12.</li>
<li>Third jumper lead into column B row 21.</li>
<li>Fourth jumper lead into column B row 30.</li>
</ul>
<div id="attachment_639" class="wp-caption alignnone" style="width: 234px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/all-jumper-cables-connected.jpg"><img class="size-medium wp-image-639" alt="All jumper cables connected" src="http://barnabypaulkent.files.wordpress.com/2013/01/all-jumper-cables-connected.jpg?w=224&#038;h=300" width="224" height="300" /></a><p class="wp-caption-text">All jumper leads connected at both ends.</p></div>
<p><strong>Connecting up the Raspberry Pi and controller cables onto the breadboard</strong></p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/vnh1kdJkGa4?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>With these components set up we need to connect one side to the Raspberry Pi GPIO pins and the other side to the radio controller. There will be five cables, one for zero volts and one each for forwards, backwards, left and right. Firstly we will concentrate on the connection to the GPIO pins.</p>
<p>Take the set of five joined together female to male jumper cables:</p>
<div id="attachment_664" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/male-to-female-jumper-leads.jpg"><img class="size-medium wp-image-664" alt="Male to female jumper leads." src="http://barnabypaulkent.files.wordpress.com/2013/01/male-to-female-jumper-leads.jpg?w=300&#038;h=168" width="300" height="168" /></a><p class="wp-caption-text">Male to female jumper cables.</p></div>
<p>The male end of the cable will go into the breadboard whereas the female end will go onto the GPIO pins. Take the purple cable and insert the male end into the row we have defined as zero volts on the breadboard as shown in the photo below:</p>
<div id="attachment_648" class="wp-caption alignnone" style="width: 234px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/zero-vaults-purple-cable-from-pi-connected-to-ground-on-breadboard.jpg"><img class="size-medium wp-image-648" alt="Zero volts purple cable from Pi connected to ground on breadboard" src="http://barnabypaulkent.files.wordpress.com/2013/01/zero-vaults-purple-cable-from-pi-connected-to-ground-on-breadboard-e1358459362662.jpg?w=224&#038;h=300" width="224" height="300" /></a><p class="wp-caption-text">Zero volts cable connected to the breadboard, the other end will go onto the GPIO pin of the Raspberry Pi.</p></div>
<p>We can now connect up the cables that will move the Pi-Car backwards, forwards left and right. The following colours are used:</p>
<ul>
<li><span style="line-height:16px;">Blue cable &#8211; backwards</span></li>
<li>Green cable &#8211; forwards</li>
<li>Yellow cable &#8211; left</li>
<li>Orange cable &#8211; right</li>
</ul>
<p>The photo below shows the blue cable connected onto the breadboard. It did not matter which row the zero volts cable went into but it does matter which row each of these cables go into. They should go in line with the second leg of the FET (the gate) and the first leg of the resistor &#8211; if you have used the numbering above this should be column E row 29:</p>
<div id="attachment_650" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/second-cable-from-pi-connected-on-breadboard.jpg"><img class="size-medium wp-image-650" alt="Blue cable from Pi connected on breadboard" src="http://barnabypaulkent.files.wordpress.com/2013/01/second-cable-from-pi-connected-on-breadboard.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">The blue cable is plugged into column E row 29 &#8211; in line with the second leg of the FET.</p></div>
<p>You can now plug in the remaining cables &#8211; the green, yellow and red cables. As with the blue cable they should go in line with the second leg (the gate) of the FET and the first leg of the resistor. If you have used the numbering above in the lesson the cables should be pushed into the breadboard as follows:</p>
<ul>
<li><span style="line-height:16px;">Green &#8211; column E, row 20</span></li>
<li>Yellow &#8211; column E, row 11</li>
<li>Orange &#8211; column E, row 2</li>
<li>Blue &#8211; column E, row 29</li>
</ul>
<div id="attachment_651" class="wp-caption alignnone" style="width: 234px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/all-cables-from-pi-connected-onto-breadboard.jpg"><img class="size-medium wp-image-651" alt="All cables from Pi connected onto breadboard" src="http://barnabypaulkent.files.wordpress.com/2013/01/all-cables-from-pi-connected-onto-breadboard.jpg?w=224&#038;h=300" width="224" height="300" /></a><p class="wp-caption-text">Cables which will go from Raspberry Pi GPIO to the breadboard.</p></div>
<p>We now need the other set of five connected male to male jumper cables which we will connect one end onto the breadboard and the other end onto the female connectors from the controller. These are shown below:</p>
<div id="attachment_636" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/male-to-male-jumper-lead.jpg"><img class="size-medium wp-image-636" alt="Male to male jumper lead" src="http://barnabypaulkent.files.wordpress.com/2013/01/male-to-male-jumper-lead.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">The five coloured male to male jumper leads.</p></div>
<p>Again we will do the zero volts cable first so take the purple cable and put it next to the other purple cable you just added from the other set of five. It could go in any row on the breadboard in the same column but we&#8217;ll put it here to keep it neat as shown in the photo below:</p>
<div id="attachment_653" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/zero-volts-from-controller-connected-to-breadboard.jpg"><img class="size-medium wp-image-653" alt="Zero volts from controller connected to breadboard" src="http://barnabypaulkent.files.wordpress.com/2013/01/zero-volts-from-controller-connected-to-breadboard.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Purple zero volts cable which will go to controller connected onto breadboard next to other purple cable.</p></div>
<p>As before the remaining coloured cables now need to be connected onto the breadboard. These will go in the same row as the first leg of the FET (the drain) in column D. The cables should be connected as follows:</p>
<ul>
<li>Blue cable &#8211; column D row 28</li>
<li>Green cable &#8211; column D row 19</li>
<li>Yellow cable &#8211; column D row 10</li>
<li>Orange cable &#8211; column D row 1</li>
</ul>
<p>The photo below shows these cables connected:</p>
<div id="attachment_654" class="wp-caption alignnone" style="width: 234px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/cables-from-pi-and-controller-connected-onto-breadboard.jpg"><img class="size-medium wp-image-654" alt="Cables from Pi and Controller connected onto breadboard" src="http://barnabypaulkent.files.wordpress.com/2013/01/cables-from-pi-and-controller-connected-onto-breadboard.jpg?w=224&#038;h=300" width="224" height="300" /></a><p class="wp-caption-text">Cables from the Raspberry Pi and the controller connected to the breadboard.</p></div>
<p><strong>Connecting the controller cables to the breadboard cables</strong></p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/OBNxPrlOlrU?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>You can now connect the cables from breadboard onto the cables coming from the controller. From the breadboard you need to select the &#8216;male&#8217; cables. These are the ones with the silver wire extending from the black connector at the end of the coloured cable.</p>
<p>Make sure you connect up the same coloured wires to each other:</p>
<div id="attachment_669" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/connecting-up-ground-purple-cable.jpg"><img class="size-medium wp-image-669" alt="Connecting up ground purple cable" src="http://barnabypaulkent.files.wordpress.com/2013/01/connecting-up-ground-purple-cable.jpg?w=300&#038;h=168" width="300" height="168" /></a><p class="wp-caption-text">Connecting the purple zero volts cable from the breadboard to the female connector coming from the controller.</p></div>
<div id="attachment_670" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/connecting-all-leads-to-controller-cables.jpg"><img class="size-medium wp-image-670" alt="Connecting all leads to controller cables" src="http://barnabypaulkent.files.wordpress.com/2013/01/connecting-all-leads-to-controller-cables.jpg?w=300&#038;h=168" width="300" height="168" /></a><p class="wp-caption-text">All cables connected up from the breadboard to the controller.</p></div>
<p><strong>Connecting the breadboard wires to the Raspberry Pi end</strong></p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/Nhwf-7jYunM?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>You now need to connect the other set of cables to complete your Pi-Car. These will be connected to the GPIO pins on the Raspberry Pi (the small prongs on the top right of the Pi shown in the photo below).</p>
<p>You do need to take care to connect them to the correct GPIO pins so please pay attention to the drawing below, it is highlighted with which colour cable should be plugged into which GPIO pin:</p>
<div id="attachment_671" class="wp-caption alignnone" style="width: 267px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/gpio-pins-to-connect-cables-to.png"><img class="size-medium wp-image-671" alt="GPIO pins to connect cables to" src="http://barnabypaulkent.files.wordpress.com/2013/01/gpio-pins-to-connect-cables-to.png?w=257&#038;h=300" width="257" height="300" /></a><p class="wp-caption-text">Highlights which colour cables should be connected into which GPIO pins.</p></div>
<ul>
<li>Purple wire &#8211; GPIO pin 6 (0 volts)</li>
<li>Blue wire &#8211; GPIO pin 11 (backwards)</li>
<li>Green wire &#8211; GPIO pin 12 (forwards)</li>
<li>Yellow wire &#8211; GPIO pin 13 (left)</li>
<li>Orange wire &#8211; GPIO pin 15 (right)</li>
</ul>
<p>The pins are numbered starting with the one at the top of the left column being &#8217;1&#8242; and the one at the top of the right column being &#8217;2&#8242;. The next one in the left column is &#8217;3&#8242;, the next one in the right column &#8217;4&#8242; and so on.</p>
<p>If you are not using the software we provide to access the GPIO pins you should be aware that they can be referred to with different numbering schemes. You can <a title="GPIO RPi wiki" href="http://elinux.org/RPi_Low-level_peripherals" target="_blank">click here</a> for more information on that. If you are using the Pi-Cars provided software such as the driving lessons and software tool box then you don&#8217;t need to worry about this at the moment.</p>
<p>Take the collection of five coloured cables coming from the breadboard and push each connector onto the correct GPIO pin as shown in the photo above and those below. The connector should push down firmly into place (click on the diagrams for larger images):</p>
<div id="attachment_674" class="wp-caption alignnone" style="width: 178px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/connect-purple-cable-to-gpio-pin-6.jpg"><img class="size-medium wp-image-674" alt="Connect purple cable to GPIO pin 6" src="http://barnabypaulkent.files.wordpress.com/2013/01/connect-purple-cable-to-gpio-pin-6.jpg?w=168&#038;h=300" width="168" height="300" /></a><p class="wp-caption-text">Connect purple cable to the GPIO pin for zero volts &#8211; GPIO pin 6.</p></div>
<div id="attachment_675" class="wp-caption alignnone" style="width: 178px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/connect-blue-cable-to-gpio-pin-11.jpg"><img class="size-medium wp-image-675" alt="Connect blue cable to GPIO pin 11" src="http://barnabypaulkent.files.wordpress.com/2013/01/connect-blue-cable-to-gpio-pin-11.jpg?w=168&#038;h=300" width="168" height="300" /></a><p class="wp-caption-text">Connect the blue cable to GPIO pin 11. This is the cable that will move the car backwards.</p></div>
<div id="attachment_676" class="wp-caption alignnone" style="width: 178px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/connect-green-to-gpio-pin-12.jpg"><img class="size-medium wp-image-676" alt="Connect green to GPIO pin 12" src="http://barnabypaulkent.files.wordpress.com/2013/01/connect-green-to-gpio-pin-12.jpg?w=168&#038;h=300" width="168" height="300" /></a><p class="wp-caption-text">Connect the green cable to GPIO pin 12 &#8211; this will be the cable that moves the Pi-Car forwards.</p></div>
<div id="attachment_677" class="wp-caption alignnone" style="width: 178px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/connect-yellow-cable-to-gpio-pin-13.jpg"><img class="size-medium wp-image-677" alt="Connect yellow cable to GPIO pin 13" src="http://barnabypaulkent.files.wordpress.com/2013/01/connect-yellow-cable-to-gpio-pin-13.jpg?w=168&#038;h=300" width="168" height="300" /></a><p class="wp-caption-text">Connect the yellow cable to GPIO pin 13. This will be the cable that moves the car left.</p></div>
<div id="attachment_678" class="wp-caption alignnone" style="width: 178px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/connect-orange-cable-to-gpio-pin-15.jpg"><img class="size-medium wp-image-678" alt="Connect orange cable to GPIO pin 15" src="http://barnabypaulkent.files.wordpress.com/2013/01/connect-orange-cable-to-gpio-pin-15.jpg?w=168&#038;h=300" width="168" height="300" /></a><p class="wp-caption-text">Connect the orange cable to GPIO pin 15 &#8211; this will be the cable that moves the car right.</p></div>
<p>A new Pi-Car is born (why don&#8217;t you name it!)</p>
<div id="attachment_751" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/pi-cars-tool-kit-all-connected-together1.jpg"><img class="size-medium wp-image-751" alt="Pi-Cars Tool Kit all connected together" src="http://barnabypaulkent.files.wordpress.com/2013/01/pi-cars-tool-kit-all-connected-together1-e1358987761864.jpg?w=300&#038;h=224" width="300" height="224" /></a><p class="wp-caption-text">Pi-Cars Tool Kit with one side connected to the controller and the other to the GPIO pins on the Raspberry Pi.</p></div>
<p><strong>Testing your Pi-Car:</strong></p>
<p><strong>Test your Pi-Car before you connect back together</strong></p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/wKf0UtAozgs?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>Now you have finished constructing your Pi-Car it is always a good idea to give it a visual inspection. Check all the wires are pressed in tightly and the there are no loose wires.</p>
<p>Firstly turn your car back on and check that it moves when you press the little switches to go forwards and backwards, left and right as shown below:</p>
<div id="attachment_597" class="wp-caption alignnone" style="width: 310px"><a href="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-switches-highlighted.jpg"><img class="size-medium wp-image-597" alt="Controller with switches highlighted" src="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-switches-highlighted.jpg?w=300&#038;h=264" width="300" height="264" /></a><p class="wp-caption-text">Controller with the switches highlighted that move the car forwards, backwards, left and right.</p></div>
<p><strong>Jump starting your Pi-Car</strong></p>
<p>Once you have confirmed this works we can now try and control the Pi-Car through the Raspberry Pi. Make sure the wires are connected to the GPIO pins on the Raspberry Pi and your Raspberry Pi is turned on.</p>
<p>The best way of testing your Pi-Car quickly is with the Jump Start guides. These enable you to move your Pi-Car in four lines of Python code or through Scratch getting the software from the Raspberry Pi Store.</p>
<p>We chose to use the Python Jump Start when we built our Tool Kit:</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/XSLI7NkRZlU?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>You can access the full instructions for the Jump Start for Python by <a title="Jump start – get your Pi-Car going as quickly as you can with Python" href="http://pi-cars.com/2012/12/22/jump-start-get-your-pi-car-going-as-quick-as-you-can/">clicking here.</a> For accessing full instructions for Jump Starting your Pi-Car with Scratch<a title="Jump start – get your Pi-Car going with the Pi Store and Scratch" href="http://pi-cars.com/2013/01/03/jump-start-get-your-pi-car-going-with-the-pi-store/"> click here.</a></p>
<p>Congratulations you have created a Pi-Car (hopefully) and you can now go on and complete the Driving lessons for Scratch and Python which will teach you about programming. <a title="Scratch Driving Lessons" href="http://pi-cars.com/tag/scratch-driving-lesson/">Click here</a> for Scratch Driving Lessons and <a title="Python Driving Lessons" href="http://pi-cars.com/tag/python-driving-lesson/">click here</a> for Python Driving Lessons.</p>
<p>If your Pi-Car is not working don&#8217;t panic &#8211; leave a comment here and try to explain any problem you had or email to info@pi-cars.com . Don&#8217;t worry if you think you have just made a really basic mistake &#8211; the reason most things in engineering don&#8217;t work comes down to simple mistakes.</p>
<h3>PDF Version</h3>
<p>PDF version of this article - <a href="http://barnabypaulkent.files.wordpress.com/2013/04/pi-cars-factory-e28093-tool-kit-_-pi-cars.pdf">Pi-Cars Factory – Tool Kit _ Pi-Cars</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/barnabypaulkent.wordpress.com/580/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/barnabypaulkent.wordpress.com/580/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pi-cars.com&#038;blog=42777588&#038;post=580&#038;subd=barnabypaulkent&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pi-cars.com/2013/01/24/pi-cars-factory-beginners-tool-kit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/bf149e636959abaa09b15d619258b985?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barnabypaulkent</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/back-of-controller-with-screw-to-remove.jpg?w=300" medium="image">
			<media:title type="html">Back of controller with screw to remove</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/top-of-controller-with-screwdriver-to-disconnect.jpg?w=300" medium="image">
			<media:title type="html">Top of Controller with screwdriver to disconnect</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/top-of-controller-with-screwdriver-pushed-in-to-disconnect.jpg?w=300" medium="image">
			<media:title type="html">Top of Controller with screwdriver pushed in to disconnect</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/top-of-controller-with-screwdriver-levered-up.jpg?w=300" medium="image">
			<media:title type="html">Top of Controller with screwdriver levered up</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/bottom-of-controller-with-screwdriver.jpg?w=300" medium="image">
			<media:title type="html">Bottom of controller with screwdriver</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-test-points1.jpg?w=300" medium="image">
			<media:title type="html">Controller with levers removed</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-switches-highlighted.jpg?w=300" medium="image">
			<media:title type="html">Controller with switches highlighted</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/multimeter-set-to-20-volts-ready-to-test.jpg?w=300" medium="image">
			<media:title type="html">Multimeter set to 20 volts ready to test</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-test-point-202-highlighted.jpg?w=300" medium="image">
			<media:title type="html">Controller with test point 202 highlighted</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-test-point-80-highlighted.jpg?w=300" medium="image">
			<media:title type="html">Controller with test point 80 highlighted</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/expanding-a-test-point-with-the-soldering-iron.jpg?w=300" medium="image">
			<media:title type="html">Expanding a test point with the Soldering iron</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-all-test-points-highlighted.jpg?w=300" medium="image">
			<media:title type="html">Controller with all test points highlighted</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/female-to-stripped-wire.jpg?w=300" medium="image">
			<media:title type="html">Female to stripped wire</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/two-wires-twisted-and-ready-two-still-not-ready.jpg?w=300" medium="image">
			<media:title type="html">Two wires twisted and ready two still not ready</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/before-tinning-the-wire-with-solder-ready.jpg?w=300" medium="image">
			<media:title type="html">Before tinning the wire with solder ready</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/tinning-the-green-wire-with-solder.jpg?w=300" medium="image">
			<media:title type="html">Tinning the green wire with solder</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/tinning-the-green-wire-with-solder-further-on.jpg?w=300" medium="image">
			<media:title type="html">Tinning the green wire with solder further on</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/feeding-cables-through-controller.jpg?w=168" medium="image">
			<media:title type="html">Feeding cables through controller</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/wires-through-ready-to-connect-to-test-points.jpg?w=168" medium="image">
			<media:title type="html">Wires through ready to connect to test points</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/snipping-the-wires-before-connection-to-the-controller.jpg?w=300" medium="image">
			<media:title type="html">Snipping the wires before connection to the controller</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/connecting-the-wires-to-the-controller.jpg?w=300" medium="image">
			<media:title type="html">Connecting the wires to the controller</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-wires-connected.jpg?w=300" medium="image">
			<media:title type="html">Controller with wires connected</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-closer-up-e1358372812985.jpg?w=224" medium="image">
			<media:title type="html">Breadboard closer up</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-one-fet-added-e1358372843362.jpg?w=224" medium="image">
			<media:title type="html">Breadboard with one FET added</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-one-fet-added-close-up.jpg?w=300" medium="image">
			<media:title type="html">Breadboard with one FET added close up</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-all-fets-added-e1358372669518.jpg?w=224" medium="image">
			<media:title type="html">Breadboard with all FETS added</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-all-fets-and-resistor-close-up.jpg?w=300" medium="image">
			<media:title type="html">Breadboard with all FETS and resistor close up</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-fets-added-and-one-resistor-added-e1358376629151.jpg?w=224" medium="image">
			<media:title type="html">Breadboard with FETS added and one resistor added</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/breadboard-with-all-fets-and-resistors-added-e1358377073794.jpg?w=224" medium="image">
			<media:title type="html">Breadboard with all FETS and resistors added</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/male-to-male-cables-for-breadboard-interconnection.jpg?w=300" medium="image">
			<media:title type="html">Male to male cables for breadboard interconnection</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/jumper-cable-inserted-between-the-fet-and-resistor.jpg?w=224" medium="image">
			<media:title type="html">Jumper cable inserted between the FET and resistor</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/jumper-cable-other-end-connected-to-the-source.jpg?w=224" medium="image">
			<media:title type="html">Jumper cable other end connected to the source</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/all-jumper-cables-connected.jpg?w=224" medium="image">
			<media:title type="html">All jumper cables connected</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/male-to-female-jumper-leads.jpg?w=300" medium="image">
			<media:title type="html">Male to female jumper leads.</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/zero-vaults-purple-cable-from-pi-connected-to-ground-on-breadboard-e1358459362662.jpg?w=224" medium="image">
			<media:title type="html">Zero volts purple cable from Pi connected to ground on breadboard</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/second-cable-from-pi-connected-on-breadboard.jpg?w=300" medium="image">
			<media:title type="html">Blue cable from Pi connected on breadboard</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/all-cables-from-pi-connected-onto-breadboard.jpg?w=224" medium="image">
			<media:title type="html">All cables from Pi connected onto breadboard</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/male-to-male-jumper-lead.jpg?w=300" medium="image">
			<media:title type="html">Male to male jumper lead</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/zero-volts-from-controller-connected-to-breadboard.jpg?w=300" medium="image">
			<media:title type="html">Zero volts from controller connected to breadboard</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/cables-from-pi-and-controller-connected-onto-breadboard.jpg?w=224" medium="image">
			<media:title type="html">Cables from Pi and Controller connected onto breadboard</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/connecting-up-ground-purple-cable.jpg?w=300" medium="image">
			<media:title type="html">Connecting up ground purple cable</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/connecting-all-leads-to-controller-cables.jpg?w=300" medium="image">
			<media:title type="html">Connecting all leads to controller cables</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/gpio-pins-to-connect-cables-to.png?w=257" medium="image">
			<media:title type="html">GPIO pins to connect cables to</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/connect-purple-cable-to-gpio-pin-6.jpg?w=168" medium="image">
			<media:title type="html">Connect purple cable to GPIO pin 6</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/connect-blue-cable-to-gpio-pin-11.jpg?w=168" medium="image">
			<media:title type="html">Connect blue cable to GPIO pin 11</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/connect-green-to-gpio-pin-12.jpg?w=168" medium="image">
			<media:title type="html">Connect green to GPIO pin 12</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/connect-yellow-cable-to-gpio-pin-13.jpg?w=168" medium="image">
			<media:title type="html">Connect yellow cable to GPIO pin 13</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/connect-orange-cable-to-gpio-pin-15.jpg?w=168" medium="image">
			<media:title type="html">Connect orange cable to GPIO pin 15</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/pi-cars-tool-kit-all-connected-together1-e1358987761864.jpg?w=300" medium="image">
			<media:title type="html">Pi-Cars Tool Kit all connected together</media:title>
		</media:content>

		<media:content url="http://barnabypaulkent.files.wordpress.com/2013/01/controller-with-switches-highlighted.jpg?w=300" medium="image">
			<media:title type="html">Controller with switches highlighted</media:title>
		</media:content>
	</item>
	</channel>
</rss>
