SlideShare a Scribd company logo
Programming the Raspberry Pi
Dr Eben Upton
Raspberry Pi Foundation
contents
• introduction
• unboxing and setup
• flashing an SD card
• logging in for the first time
• the JOE text editor
• running the “hello world” program• running the “hello world” program
• a (slightly) more complex example
• an OpenGL ES graphics program in C
• the configuration file
• wrap up
introduction
• Raspberry Pi is a small, cheap
ARM-based PC for education
and hobbyists
• Runs Debian GNU/Linux from
an SD card
– Standard image available from
Feature Specification
CPU 700MHz ARM1176-JZFS
GPU Broadcom VideoCore IV
Memory 256MB LPDDR2-800
Video HDMI, composite
Audio HDMI, stereo analog
– Standard image available from
http://www.element14.com
– Includes a broad range of tools and
examples
• General-purpose IO connector
allows simple interfacing
Audio HDMI, stereo analog
USB 2 x USB2.0 (model B)
Storage SD card
Networking 10/100 Ethernet
Power 5V micro USB
unboxing
a quick tour
a quick tour
Power
a quick tour
Power
HDMI
a quick tour
Power
HDMI
Ethernet
a quick tour
Power
HDMI
Ethernet
USB
a quick tour
Audio
Power
HDMI
Ethernet
USB
a quick tour
Audio
Video
Power
HDMI
Ethernet
USB
a quick tour
Audio
Video
Power
GPIO
HDMI
Ethernet
USB
a quick tour
Audio
Video
Power
GPIO
SD
HDMI
Ethernet
USB
cables and accessories
putting it all together
putting it all together
flashing an SD card
• You may have purchased a pre-
installed card
• Otherwise, you will need to
– Download an image and a copy of
the tool dd-removable from
www.element14.com/raspberrypi
– Flash the image onto a 2GB SD
card from a Windows PC
• Insert the card into a card reader
• At a command prompt, type
– dd-removable --list
– dd-removable bs=1M if=sd.img of= ?DeviceHarddisk<X>Partition0 -progress
– Substituting the appropriate number for <X>
flashing an SD card
flashing an SD card
• You may have purchased a pre-
installed card
• Otherwise, you will need to
– Download an image and a copy of
the tool dd-removable from
www.element14.com/raspberrypi
– Flash the image onto a 2GB SD
card from a Windows PC
• Insert the card into a card reader
• At a command prompt, type
– dd-removable --list
– dd-removable bs=1M if=sd.img of= ?DeviceHarddisk<X>Partition0 -progress
– Substituting the appropriate number for <X>
logging in for the first time
• Insert a card
• Apply power to the device
• Red LED should come on
• After 5 seconds
– Green LED should begin to flicker
– Text should appear on the screen– Text should appear on the screen
• At the login prompt
enter the username pi, and
password raspberry
• You may want to set the clock!
logging in for the first time
logging in for the first time
• Insert a card
• Apply power to the device
• Red LED should come on
• After 5 seconds
– Green LED should begin to flicker
– Text should appear on the screen– Text should appear on the screen
• At the login prompt
enter the username pi, and
password raspberry
• You may want to set the clock!
the JOE text editor
• Standard image bundles JOE
– Simple programmer’s text editor
– Syntax highlighting for Python and C
• At the command line, type
joe helloworld.py
• When the editor appears, type• When the editor appears, type
print “hello world”
• Now type Ctrl+K and then X to
save and exit
• More documentation available at
http://joe-editor.sourceforce.net
the JOE text editor
the JOE text editor
• Standard image bundles JOE
– Simple programmer’s text editor
– Syntax highlighting for Python and C
• At the command line, type
joe helloworld.py
• When the editor appears, type• When the editor appears, type
print “hello world”
• Now type Ctrl+K and then X to
save and exit
• More documentation available at
http://joe-editor.sourceforce.net
running the “hello world” program
• We just wrote our first program!
• We can run it using the bundled
Python interpreter
• At the command line, type
python helloworld.py
• The text “hello world” will appear• The text “hello world” will appear
• You can also run Python in
“interactive mode” by just typing
python
• A great way to experiment with
the language
running the “hello world” program
running the “hello world” program
• We just wrote our first program!
• We can run it using the bundled
Python interpreter
• At the command line, type
python helloworld.py
• The text “hello world” will appear• The text “hello world” will appear
• You can also run Python in
“interactive mode” by just typing
python
• A great way to experiment with
the language
a (slightly) more complex program
• A series of examples, building up to a simple game of Snake, can be
downloaded and unpacked by typing
wget http://www.raspberrypi.org/game.tar.gz
tar xvfz game.tar.gz
a (slightly) more complex program
a (slightly) more complex program
a (slightly) more complex program
• A series of examples, building up to a simple game of Snake, can be
downloaded and unpacked by typing
wget http://www.raspberrypi.org/game.tar.gz
tar xvfz game.tar.gz
an OpenGL ES graphics program in C
• Raspberry Pi incorporates a
powerful graphics accelerator
• We bundle a simple example
– Written in C, using OpenGL ES
– Source can be found in
/opt/vc/src/hello_pi/hello_triangle/opt/vc/src/hello_pi/hello_triangle
• To run the example
– Change directory using cd
– Build it using make
– Run it by typing ./hello_triangle.bin
• Try editing the source and the
makefile using JOE
an OpenGL ES graphics program in C
an OpenGL ES graphics program in C
• Raspberry Pi incorporates a
powerful graphics accelerator
• We bundle a simple example
– Written in C, using OpenGL ES
– Source can be found in
/opt/vc/src/hello_pi/hello_triangle/opt/vc/src/hello_pi/hello_triangle
• To run the example
– Change directory using cd
– Build it using make
– Run it by typing ./hello_triangle.bin
• Try editing the source and the
makefile using JOE
an OpenGL ES graphics program in C
• More complicated examples available online, including Quake 3 at
https://github.com/raspberrypi/quake3
an OpenGL ES graphics program in C
an OpenGL ES graphics program in C
an OpenGL ES graphics program in C
• More complicated examples available online, including Quake 3 at
https://github.com/raspberrypi/quake3
the configuration file (advanced users)
• At startup, Raspberry Pi reads
config.txt from the SD card
– Controls display and overclocking
– Edit from a PC or on device using
joe /boot/config.txt
• Common options include
• A typical configuration file
# select 16:9 PAL
sdtv_mode=2
sdtv_aspect=3
• Common options include
– arm_freq set ARM clock speed
– gpu_freq set GPU clock speed
– sdtv_mode select PAL/NTSC
– hdmi_mode force HDMI resolution
– overscan_* set screen border
• Very easy to break your install
# medium size borders
overscan_left=28
overscan_right=28
overscan_top=16
overscan_bottom=16
wrap up
• We’ve seen how to
– Set up, boot and configure your Raspberry Pi
– Create and edit text files using the JOE editor
– Run a simple Python script
– Download and unpack more examples
– Build and run one of the bundled C programs– Build and run one of the bundled C programs
• Remember Raspberry Pi is just a GNU/Linux box
– Many books and online tutorials available
• Don’t be afraid to play around with software
– At worst you’ll have to reflash your SD card

More Related Content

PDF
Raspberry Pi Hacks
PPTX
Raspberry Pi Using Python
PPTX
Pi Is For Python
PPTX
Raspberry pi
PPTX
Raspberry Pi Free Session - 20_09_2014
ODP
DigiPinguïns: demo Raspberry Pi (Koen De Smet)
PPTX
Raspberry Pi (Introduction)
Raspberry Pi Hacks
Raspberry Pi Using Python
Pi Is For Python
Raspberry pi
Raspberry Pi Free Session - 20_09_2014
DigiPinguïns: demo Raspberry Pi (Koen De Smet)
Raspberry Pi (Introduction)

What's hot (19)

PPTX
Python in raspberry pi
ODP
Introduction to Raspberry Pi and GPIO
PPT
Console development
ODP
Raspberry Pi and Amateur Radio
PPTX
Exploring the abc's of raspberry pi and python(day 2)
PPTX
Raspberry
PPTX
Exploring the ABC's of Raspberry Pi with Python
PPTX
Coffee & Pi - Everything RetroPie
PPTX
Up and running with Raspberry Pi
PPTX
Getting Started with Raspberry Pi and Arduino
PDF
My presentation raspberry pi
ODP
Connecting Hardware to the Web with the BeagleBone
PDF
Taking the BeagleBone Cookbook recipes beyond BeagleBone Black
PPTX
introduction to Raspberry pi
PDF
Hadoop on raspberry pi PART 1
PDF
Raspberry Pi, Arduino and the Maker Movement
PDF
Interfacing the Raspberry Pi to the World
PPTX
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
PDF
Presentazione
Python in raspberry pi
Introduction to Raspberry Pi and GPIO
Console development
Raspberry Pi and Amateur Radio
Exploring the abc's of raspberry pi and python(day 2)
Raspberry
Exploring the ABC's of Raspberry Pi with Python
Coffee & Pi - Everything RetroPie
Up and running with Raspberry Pi
Getting Started with Raspberry Pi and Arduino
My presentation raspberry pi
Connecting Hardware to the Web with the BeagleBone
Taking the BeagleBone Cookbook recipes beyond BeagleBone Black
introduction to Raspberry pi
Hadoop on raspberry pi PART 1
Raspberry Pi, Arduino and the Maker Movement
Interfacing the Raspberry Pi to the World
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
Presentazione
Ad

Viewers also liked (12)

PDF
The mag pi_issue_8
PDF
Instalar twonky En Synology
PDF
Mag pi18 Citation "PhotoReportage"
PDF
Raspbian
PDF
Raspberry Pi ® User Guide
PDF
The mag pi-issue-28-en
PDF
"Are you what you sign? " Arnaud Velten Interview for Cyber Security Trends ...
DOCX
HOME AUTOMATION USING ARDUINO
The mag pi_issue_8
Instalar twonky En Synology
Mag pi18 Citation "PhotoReportage"
Raspbian
Raspberry Pi ® User Guide
The mag pi-issue-28-en
"Are you what you sign? " Arnaud Velten Interview for Cyber Security Trends ...
HOME AUTOMATION USING ARDUINO
Ad

Similar to Programming the Raspberry Pi element14 (20)

PPTX
Starting Raspberry Pi
PDF
Hacking and Forensics on the Go - 44CON 2012
PDF
Polstra 44con2012
ODP
The Deck by Phil Polstra GrrCON2012
PPTX
Raspberry pi
PPTX
Raspberry pi complete setup
PPTX
Raspbeery Pi : An Introduction
PPTX
Introduction To Raspberry Pi with Simple GPIO pin Control
PDF
Feature satip4
PDF
Feature satip4
PDF
Feature satip4
PDF
Feature satip4
PDF
Feature satip4
PPTX
Tac Presentation October 72014- Raspberry PI
PPTX
introduction to Raspberry pi
PPT
Beagle board101 esc-boston-2009b
ODP
Raspberry Pi introduction
PDF
Feature satip4
PDF
Feature satip4
PPT
Porting To Symbian
Starting Raspberry Pi
Hacking and Forensics on the Go - 44CON 2012
Polstra 44con2012
The Deck by Phil Polstra GrrCON2012
Raspberry pi
Raspberry pi complete setup
Raspbeery Pi : An Introduction
Introduction To Raspberry Pi with Simple GPIO pin Control
Feature satip4
Feature satip4
Feature satip4
Feature satip4
Feature satip4
Tac Presentation October 72014- Raspberry PI
introduction to Raspberry pi
Beagle board101 esc-boston-2009b
Raspberry Pi introduction
Feature satip4
Feature satip4
Porting To Symbian

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
A Presentation on Artificial Intelligence
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
cuic standard and advanced reporting.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Empathic Computing: Creating Shared Understanding
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Unlocking AI with Model Context Protocol (MCP)
Per capita expenditure prediction using model stacking based on satellite ima...
MIND Revenue Release Quarter 2 2025 Press Release
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
A comparative analysis of optical character recognition models for extracting...
MYSQL Presentation for SQL database connectivity
A Presentation on Artificial Intelligence
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Building Integrated photovoltaic BIPV_UPV.pdf
Network Security Unit 5.pdf for BCA BBA.
Agricultural_Statistics_at_a_Glance_2022_0.pdf
20250228 LYD VKU AI Blended-Learning.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The AUB Centre for AI in Media Proposal.docx
Advanced methodologies resolving dimensionality complications for autism neur...
Encapsulation_ Review paper, used for researhc scholars
cuic standard and advanced reporting.pdf
Programs and apps: productivity, graphics, security and other tools
Empathic Computing: Creating Shared Understanding
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows

Programming the Raspberry Pi element14

  • 1. Programming the Raspberry Pi Dr Eben Upton Raspberry Pi Foundation
  • 2. contents • introduction • unboxing and setup • flashing an SD card • logging in for the first time • the JOE text editor • running the “hello world” program• running the “hello world” program • a (slightly) more complex example • an OpenGL ES graphics program in C • the configuration file • wrap up
  • 3. introduction • Raspberry Pi is a small, cheap ARM-based PC for education and hobbyists • Runs Debian GNU/Linux from an SD card – Standard image available from Feature Specification CPU 700MHz ARM1176-JZFS GPU Broadcom VideoCore IV Memory 256MB LPDDR2-800 Video HDMI, composite Audio HDMI, stereo analog – Standard image available from http://www.element14.com – Includes a broad range of tools and examples • General-purpose IO connector allows simple interfacing Audio HDMI, stereo analog USB 2 x USB2.0 (model B) Storage SD card Networking 10/100 Ethernet Power 5V micro USB
  • 15. putting it all together
  • 16. putting it all together
  • 17. flashing an SD card • You may have purchased a pre- installed card • Otherwise, you will need to – Download an image and a copy of the tool dd-removable from www.element14.com/raspberrypi – Flash the image onto a 2GB SD card from a Windows PC • Insert the card into a card reader • At a command prompt, type – dd-removable --list – dd-removable bs=1M if=sd.img of= ?DeviceHarddisk<X>Partition0 -progress – Substituting the appropriate number for <X>
  • 19. flashing an SD card • You may have purchased a pre- installed card • Otherwise, you will need to – Download an image and a copy of the tool dd-removable from www.element14.com/raspberrypi – Flash the image onto a 2GB SD card from a Windows PC • Insert the card into a card reader • At a command prompt, type – dd-removable --list – dd-removable bs=1M if=sd.img of= ?DeviceHarddisk<X>Partition0 -progress – Substituting the appropriate number for <X>
  • 20. logging in for the first time • Insert a card • Apply power to the device • Red LED should come on • After 5 seconds – Green LED should begin to flicker – Text should appear on the screen– Text should appear on the screen • At the login prompt enter the username pi, and password raspberry • You may want to set the clock!
  • 21. logging in for the first time
  • 22. logging in for the first time • Insert a card • Apply power to the device • Red LED should come on • After 5 seconds – Green LED should begin to flicker – Text should appear on the screen– Text should appear on the screen • At the login prompt enter the username pi, and password raspberry • You may want to set the clock!
  • 23. the JOE text editor • Standard image bundles JOE – Simple programmer’s text editor – Syntax highlighting for Python and C • At the command line, type joe helloworld.py • When the editor appears, type• When the editor appears, type print “hello world” • Now type Ctrl+K and then X to save and exit • More documentation available at http://joe-editor.sourceforce.net
  • 24. the JOE text editor
  • 25. the JOE text editor • Standard image bundles JOE – Simple programmer’s text editor – Syntax highlighting for Python and C • At the command line, type joe helloworld.py • When the editor appears, type• When the editor appears, type print “hello world” • Now type Ctrl+K and then X to save and exit • More documentation available at http://joe-editor.sourceforce.net
  • 26. running the “hello world” program • We just wrote our first program! • We can run it using the bundled Python interpreter • At the command line, type python helloworld.py • The text “hello world” will appear• The text “hello world” will appear • You can also run Python in “interactive mode” by just typing python • A great way to experiment with the language
  • 27. running the “hello world” program
  • 28. running the “hello world” program • We just wrote our first program! • We can run it using the bundled Python interpreter • At the command line, type python helloworld.py • The text “hello world” will appear• The text “hello world” will appear • You can also run Python in “interactive mode” by just typing python • A great way to experiment with the language
  • 29. a (slightly) more complex program • A series of examples, building up to a simple game of Snake, can be downloaded and unpacked by typing wget http://www.raspberrypi.org/game.tar.gz tar xvfz game.tar.gz
  • 30. a (slightly) more complex program
  • 31. a (slightly) more complex program
  • 32. a (slightly) more complex program • A series of examples, building up to a simple game of Snake, can be downloaded and unpacked by typing wget http://www.raspberrypi.org/game.tar.gz tar xvfz game.tar.gz
  • 33. an OpenGL ES graphics program in C • Raspberry Pi incorporates a powerful graphics accelerator • We bundle a simple example – Written in C, using OpenGL ES – Source can be found in /opt/vc/src/hello_pi/hello_triangle/opt/vc/src/hello_pi/hello_triangle • To run the example – Change directory using cd – Build it using make – Run it by typing ./hello_triangle.bin • Try editing the source and the makefile using JOE
  • 34. an OpenGL ES graphics program in C
  • 35. an OpenGL ES graphics program in C • Raspberry Pi incorporates a powerful graphics accelerator • We bundle a simple example – Written in C, using OpenGL ES – Source can be found in /opt/vc/src/hello_pi/hello_triangle/opt/vc/src/hello_pi/hello_triangle • To run the example – Change directory using cd – Build it using make – Run it by typing ./hello_triangle.bin • Try editing the source and the makefile using JOE
  • 36. an OpenGL ES graphics program in C • More complicated examples available online, including Quake 3 at https://github.com/raspberrypi/quake3
  • 37. an OpenGL ES graphics program in C
  • 38. an OpenGL ES graphics program in C
  • 39. an OpenGL ES graphics program in C • More complicated examples available online, including Quake 3 at https://github.com/raspberrypi/quake3
  • 40. the configuration file (advanced users) • At startup, Raspberry Pi reads config.txt from the SD card – Controls display and overclocking – Edit from a PC or on device using joe /boot/config.txt • Common options include • A typical configuration file # select 16:9 PAL sdtv_mode=2 sdtv_aspect=3 • Common options include – arm_freq set ARM clock speed – gpu_freq set GPU clock speed – sdtv_mode select PAL/NTSC – hdmi_mode force HDMI resolution – overscan_* set screen border • Very easy to break your install # medium size borders overscan_left=28 overscan_right=28 overscan_top=16 overscan_bottom=16
  • 41. wrap up • We’ve seen how to – Set up, boot and configure your Raspberry Pi – Create and edit text files using the JOE editor – Run a simple Python script – Download and unpack more examples – Build and run one of the bundled C programs– Build and run one of the bundled C programs • Remember Raspberry Pi is just a GNU/Linux box – Many books and online tutorials available • Don’t be afraid to play around with software – At worst you’ll have to reflash your SD card