Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Thomas Sabu
Team Lead | R&D
Neo Green Labs, Kochi
Contents
Raspberry Pi Intro
Familiarizing RPi Mini Computer
OS for RPi
Loading OS in to SD Card
Using RPi Computer
Introduction to Python
Python Programming
Blinking LED
Dislove
Raspberry Pi
Mini Computer
Applications
Low Cost Computer
Controlling the real world
Different Raspberry Pi Boards
Rpi 3 B
RPi 2 B+
Rpi 2 B
Rpi 1 B
Rpi 1 A+
Rpi 1 A
Working with RPi
Download the OS from Internet
Load OS in to the SD Card
Boot the RPi with OS
Develop your applications!
Operating System for Raspberry Pi
Raspbian
Windows 10 IOT
Loading OS in to SD Card
OS: Raspbian Jessie
Micro SD Card (8GB Class 10)
Tools Required
Winrar
Win32disk imager
Familiarize your RPi Computer
Programming Language
Basic
C
C++
Java
Python
Python Programming Environment
Familiarize it
Python
A simple & powerful Language
Programming with Python: Steps
open python
write the code
save the code with a name with an
extension .py
hello.py
run the code
Our first program
Write a program to Display
Hello! Whatsup??
Displaying a Character or
sentence
print
eg: print Hello! Whatsup??
Storing a Number, Character or
Sentence in the memory
(variable)
a=10
b=5
q=a
p=hello
print a
print b
print q
print p
print a,b,q,p
Mathematic Calculations
+ - * / %
Program to find the sum, difference
product and division of two numbers
a=18
b=6
c=a+b
d=a-b
e=a*b
d=a/b
print c
print d
print e
print d
Getting input from you / any other
user
int(raw_input())
a=1
b=2
c=3
d=4
e=5
print a,b,c,d,e
Another method
a=1
print a
a=a+1
print a
a=a+1
print a
a=a+1
print a
a=a+1
print a
Easy method (using Loop)
a=1
print a
Four times
a=a+1
Using For loop
for a in range(1,6,1):
print a
Print the first natural numbers up
to a limit given by the user
n=int(raw_input(enter the limiting number))
for a in range(1,n,1):
print a
Find the sum of first n natural
numbers, where n is the limiting
number given by the user
Using While loop
a=1
while(a<6):
print a
a=a+1
Print the first integers up to a limit
given by the user
n=int(raw_input(enter the limiting number))
a=1
while (a<n):
print a
a=a+1
Find the sum of first n integers,
where n is the limiting number
given by the user
To find the largest of two numbers
a=5
b=10
if a>b:
print the largest number is:
print a
else:
print the largest number is:
print b
Find the largest of two numbers
given by the user
Find the smallest of two numbers
given by the user
Find the largest of first n numbers,
where n is the limit entered by the
user
n=int(raw_input(enter the limiting number))
a=1
b=1
while (a<n):
if a>b:
b=a
a=a+1
print the largest number is
print b
Interesting Applications of
Raspberry Pi
It can turn on an LED as per your
program
It can turn off and led as per your
program
It can blink an led
It can turn on/off an led when u press a
switch
How is it possible
Through the input / output pins on the
raspberry pi
RPi 2 Model B+ GPIO Header
LED
Turning on led with a battery
Connect the LED to the raspberry
pi
Can you turn it off without
disconnecting the wire???
Input output LIBRARY
First line of your program
import RPi.GPIO as GPIO
Functions
Second line of code
GPIO.setmode(GPIO.BOARD)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)
GPIO.output(11, GPIO.HIGH)
Blinking an LED
Means
Turn on the led
wait for some time
turn off the led
Wait for some time
To wait for some time
You need another library
import time
Thomas Sabu
thomas@neogreenlabs.com
9495242563