Download as odp, pdf, or txt
Download as odp, pdf, or txt
You are on page 1of 33

Indonesia Creative Open Source

Software
2015

Raspberry Pi Workshop
Oleh: Tulus Budyarso

Agenda

A Quick Start Guide


Installation of Raspbian OS
Building File Server with Raspberry Pi
GPIO Raspberry Pi

A Quick Start Guide

Credit card size single


board computer or a
Programmable PC
Developed in U.K. by
Raspberry - Pi foundation
in 2009
Great tool for Learning
Programming,
Computers & Concepts of
Embedded Linux, etc
Very Low Cost

Features Model B

Raspberry Pi Component

Raspberry Pi Models

Installation of Raspbian
OS

Installation tools
For Windows
SDFormatter.exe
Win32DiskImager.exe

For Linux
$$dd

Procedure in Windows
Download Raspbian OS from:
http://downloads.raspberrypi.org/raspbian_latest

Format your SD Card using SDFormatter.exe

Install & run Win32DiskImager.exe

Procedure in Linux
Download Raspbian OS from:
http://downloads.raspberrypi.org/raspbian_latest

Format SD Card in FAT 32/ext2


sudo dd bs=4m if=<name_of_image>.img of=<device name>

Example
sudo dd bs=4m if=2013-02-09-wheezy-raspbian.img of=/dev/sdb

Setup Your Repository


Adjust your sources.list file :
sudo nano /etc/apt/sources.list
We will use local repository in this workshop
$
$
$
$

deb http://kambing.ui.ac.id/raspbian/raspbian
wheezy main contrib non-free
deb-src http://kambing.ui.ac.id/raspbian/raspbian
wheezy main contrib non-free

Building File Server With Raspberry


Pi

Install the samba software


Update and Upgrade Raspbian:
$ sudo apt-get update | sudo apt-get upgrade
Install samba:
$ sudo apt-get install samba samba-commonbin
Rename your default samba configuration file:
$ sudo mv /etc/samba/smb.conf
/etc/samba/smb.conf.old

Configure Samba Server


Create public folder
$ sudo mkdir /home/shares/public
! Change The Permission. Warning : Don't Do This on Secure
Setup

$ sudo chmod 777 /home/shares/public


Create new configuration file
$ sudo nano /etc/samba/smb.conf

Configure Samba Server


[global]
create mode = 664
workgroup = RASPBERRYPI
security = SHARE
usershare allow guest = yes

Configure Samba Server


[public]
comment = shared
path = /home/shares/public
guest ok = yes
read only = no
public = yes
writeable = yes

Configure Samba Server


Restart samba to use the new configuration file.
sudo /etc/init.d/samba restart

Configuring the Samba client on a


Windows PC
Right Click on Computer Map Network Drive

Configuring the Samba client on a


Windows PC

Configuring the Samba client on a


Linux PC
Open a file manager (e.g. nautilus, thunar) and
enter

smb://raspberrypi/

Or :

smb://$SMB_HOST_IP/

GPIO Raspberry Pi

Basic Output

#!/usr/bin/python
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17,GPIO.OUT)
GPIO.setup(21,GPIO.OUT)
GPIO.setup(22,GPIO.OUT)

try:
while 1:
GPIO.output(17,GPIO.HIGH)
GPIO.output(21,GPIO.HIGH)
GPIO.output(22,GPIO.HIGH)
time.sleep(1)
GPIO.output(17,GPIO.LOW)
GPIO.output(21,GPIO.LOW)
GPIO.output(22,GPIO.LOW)
time.sleep(1)
finally:
GPIO.cleanup()

Basic Input

#!/usr/bin/python
import os
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(24, GPIO.IN)
print("------------------")
print(" Button + GPIO ")
print("------------------")

print GPIO.input(24)
while True:
if ( GPIO.input(24) == False
):
print("Button Pressed")
os.system('date')
print GPIO.input(10)
time.sleep(5)
else:
os.system('clear')
print ("Waiting for you
to press a button")
time.sleep(1)

Combining Input and Output

#!/usr/bin/python
import os
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(10, GPIO.IN)
GPIO.setup(17,GPIO.OUT)
GPIO.setup(21,GPIO.OUT)
GPIO.setup(22,GPIO.OUT)
print("------------------")
print(" Button + GPIO ")
print("------------------")

print GPIO.input(10)
while True:
if ( GPIO.input(10) == False
):
GPIO.output(17,GPIO.HIGH)
GPIO.output(21,GPIO.HIGH)
GPIO.output(22,GPIO.HIGH
else:
GPIO.output(17,GPIO.LOW)
GPIO.output(21,GPIO.LOW)
GPIO.output(22,GPIO.LOW
time.sleep(1)

Thank You

You might also like