sparkfun
SHOP LEARN BLOG SUPPORT
Python Programming Tutorial: Getting Started with the
Raspberry Pi
CONTRIBUTORS: fp SHAWNHYMEL
FAVORITE 7
Introduction
‘The Raspberry Pi is an amazing single board computer (SBC) capable of running Linux and a whole host of
applications. Python is a beginner-friendly programming language that is used in schools, web development,
scientific research, and in many other industries. This guide will walk you through writing your own programs
with Python to blink tights, respond to button pushes, read sensors, and log data on the Raspberry Pi.
Notice: This tutorial was written with Raspbian version "April 2018" and Python version 3.5.3. Other
versions may affect how some of the steps in this guide are performed.
Required Materials
‘To work through the activities in this tutorial, you will need a few pieces of hardware:
Python Programming Tutorial sparkFun Wish List
SparkFun Digital Temperature Sensor Breakout - TMP102
SEN-12914
‘The TMP102 is an easy-to-use digital temperature sensor from Texas Instruments. The TMP102 breakout allo
‘Trimpot 10K with Knob
coM-09806
There are lots of trimpots out there. Some are very large, some so small they require a screwdriver. Here at Sp.
Mini Photocell
SEN-02088,
This is a very small light sensor. A photocell changes (also called a [phatodetector|http:/en.wikipedia.org/wiki.
@R_ Analog to Digital Converter - MCP3002
COM-08696
hitps:learn.sparkfun.comitutorials/pythor-programming-tutoria-geting-started-with-the-raspbery-pilall 1153ror018 Python Programming Tutor: Getng Started withthe Raspbery Fi -leam sparkun com
The MCP3002 has a 10-bit analog to digital converter (ADC) with a simple to use SPI interface, Use this IC ify...
= Hamburger Mini Speaker
wee cone 4023
This willbe a treat for your ears! The Hamburger Mini Speaker is a 3W economical speaker option for any proj.
Resistor 10K Ohm 1/4 Watt PTH - 20 pack (Thick Leads)
PRT-14491
Raspberry Pi 3 B+ Starter Kit
KIT-14844
‘There's a lt of Raspberry Pi information going around lately. Whether it’s Pi A, A+, B, B+, or PI2.B, any forum
Optional Materials
You have several options when it comes to working with the Raspberry Pi. Most commonly, the Pi is used as a
standalone computer, which requires a monitor, keyboard, and mouse (listed below). To save on costs, the Pi
can also be used as a headless computer (without a monitor, keyboard, and mouse). This setup has a slightly
more difficult learning curve, as you will need to use the command-line interface (CLI) from another computer.
> 4
1
pay
a
Raspberry Pi LCD - 7" Touchscreen ‘SmartiPi Touch
@ Lcp-13733 @ prt-14059
$64.95 $24.95
wk kw 36 wk kk ts
Multimedia Wireless Keyboard
@ wic-14271
$29.95
wk eK?
@ Please note: If you have trouble seeing any of the images throughout this tutorial, feel free to click on
it to get a better look!
Open Source!
This guide is licensed under the Creative Commons Attribution Share-Alike 4.0 International License.
hitps:learn.sparkfun.comutovials/pythor-programming-tutoria-geting-started-with-the-raspbery-plll
2183ro16/2018 Python Programming Tutoiat Getting Started withthe Raspberry Pi -leam sparkfun.com
python’
Want more Python?
We are working on more tutorials, blogs, and product releases around the Python programming
language
Would you like to be notified when new content is available?
Email"
Would you also tke to subscribe to SparkFun's wockly nowesetor?
Yes, sign me up!
Install the OS
‘You have a few options when it comes to interacting with the Raspberry Pi. The first and most common is to
use it ike you would a full desktop computer (just smaller), This involves connecting a keyboard, mouse, and
monitor. With this setup, you are likely best served by installing Raspbian with Desktop, which gives you a full
graphical user interface (GUI) to work with. This is the best option if you want an experience similar to working
with other operating systems (OS), such as Windows, macOS, or other popular Linux flavors, like Ubuntu
Option 1: Use the Raspberry Pi like a full computer with keyboard, mouse, and monitor
hitps:learn.sparkfun.comutovials/pythor-programming-tutoria-geting-started-with-the-raspbery-plll 353