0% found this document useful (0 votes)
15 views21 pages

Unit 2 - RaspberryPi

The document provides an introduction to the Raspberry Pi, detailing its setup, usage as a desktop computer, and programming with Python. It covers essential topics such as connecting peripherals, using the terminal, and working with GPIO for sensor interaction. Additionally, it includes troubleshooting tips for common programming errors and hardware connections.

Uploaded by

kishoreunix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views21 pages

Unit 2 - RaspberryPi

The document provides an introduction to the Raspberry Pi, detailing its setup, usage as a desktop computer, and programming with Python. It covers essential topics such as connecting peripherals, using the terminal, and working with GPIO for sensor interaction. Additionally, it includes troubleshooting tips for common programming errors and hardware connections.

Uploaded by

kishoreunix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

Introduction to the Raspberry

Pi
Agenda
• FIRST STEPS
• What is a Raspberry Pi?
• Setting up your Raspberry Pi
• Using your Raspberry Pi as a Desktop
Computer
• PROGRAMMING WITH PYTHON
• Start Programming in Python
• Write your own Function
• Using GPIO to drive outputs and read
inputs
FIRST STEPS
What is a Raspberry Pi?
• A credit-card-sized computer
• Runs on several operating
systems
Raspbian WE WILL USE
RASPBIAN
Windows 10 IoT Core
RetroPie
OpenElec
• Possible to connect with a
variety of sensors to interact with
the physical world.
•Make decisions based on processing of
gathered sensor data
Getting started with your Raspberry Pi
Basic 1-2-3
1.Connect the Raspberry Pi to
the keyboard, mouse and the
screen.
2.Plug in the power and wait
for it to boot.
3.Username : pi
Password : raspberry
(should not be needed)
Using you Raspberry Pi as a Desktop
Computer
• Try to access the internet through your Raspberry Pi and find a
picture that reflects your group. Hands up when you are done, for
help if needed!
• Save this picture to the desktop.
Communicating through the terminal
• Start the terminal by going to
Accessories and then
clicking on the Terminal
program.

• Run through the commands


and get a feel for how to
change directories, and list
its contents.
PROGRAMMING WITH PYTHON
Programming in Python3
• General-purpose programming language used for scientific and
numerical applications as well as desktop and web applications.
• Open source language that has a lot of online resources for
problems you might come across.
• We are using Thonny IDE for programming with Python3 in our
Raspberry Pi 3 Model B
• https://stackoverflow.com is your best friend for programming
troubles
The GPIO
layout

General
Purpose
Input /
Output
Use the GPIO to drive outputs and read inputs
• Build the circuit in the figure.
Use 470 Ohm resistor
• Next we will make a program
that makes one LED blink on
and off, and the other dim up
and down in idensity when
the Button is pressed.
Use the GPIO to drive outputs and read inputs
Use the GPIO to drive outputs and read inputs
Common errors and debugging
• Python is sensetive to intendation.

• Make sure that the variables and the functions have the same
exact writing. Watch out for small and Capital letters!

• Remember that python starts counting from zero.


i.e when using loops.
Using a sensor with the Raspberry Pi
• The GPIO on the Raspberry Pi can only handle a maximum of
3.3V, but many of the available sensors can return a signal of 5V
to the GPIO. This will damage the Raspberry Pi.
• How do we deal with this?
• Resistors connected as voltage dividers.
• Important to be aware of this.
Measuring Distance with a Ultrasonic Sensor: HC-
SR04

• The Trigger sends a burst of


sound that bounces and hits the
Echo.
• If we measure the time it takes
from sending to receiving we can
calculate the distance.
• NOTE: Two different resistors
here
Setting up the Raspberry Pi
Now we need a function to calculate the
distance
• With the sensor we can measure the time it takes for a signal to
be sent out and reflected back.
• We need to convert the elapsed time to distance by using the
speed of sound in air and multiplying it with the time divided by
two (Because it travels to the object, and back).
The distance function
Making it loop until we tell it to stop
If the program is not giving any measurements
• Check the wiring!

• Check you code one more time.

• Check the resistors

• Check the wiring!

You might also like