26
Pi Maker Workshop Powered by: 5.Play Time http://www.inventrom.com/ http://www.robotechlabs.com/ Mayank Joneja botmayank.wordpress.com [email protected]

5.Playtime

Embed Size (px)

DESCRIPTION

This is a part of the slide set used at the MakerSpace Noida (India) launch event, Pi Maker Workshop. This slide set is designed to help people get started with the Raspberry Pi and also serves as a collection of innovative projects and some core basic concepts that can aid anybody with their first few steps into the world of DIY electronics or maybe serve as a refresher for the experienced. Feel free to refer and share but please don't alter the watermarks :)

Citation preview

Page 1: 5.Playtime

Pi Maker

Workshop

Powered by:

5.Play Time

http://www.inventrom.com/http://www.robotechlabs.com/

Mayank Jonejabotmayank.wordpress.com

[email protected]

Page 2: 5.Playtime

Mayank Joneja

Play music on switch press

import RPi.GPIO as GPIO

from time import sleep

from subprocess import call

GPIO.setmode(GPIO.BOARD)

GPIO.setup(11,GPIO.IN)

GPIO.setup(7,GPIO.IN)

while True:

button1 = GPIO.input(11)

button2 = GPIO.input(7)

if button 1 == True:

print “Button 1 pressed”

call(‘omxplayer song1.mp3’)

if button 2 == True:

print “Button 2 pressed”

call(‘omxplayer song2.mp3’)

Page 3: 5.Playtime

Mayank Joneja

Sonic Pi

Sonic Pi is an open source programming

environment designed to explore and

teach programming concepts through

the process of creating new sounds

Sonic Pi comes with an

associated scheme of work which

emphasizes the importance

of creativity in the learning process and

gives users the control to turn their sonic

ideas into reality

Page 4: 5.Playtime

Mayank Joneja

sudo apt-get update

sudo apt-get install sonic-pi

play 60

play 60

play 65

play 60

sleep 0.25

play 65

sleep 0.5

play 72

Page 5: 5.Playtime

Mayank Joneja

Play Music over Bluetooth

http://www.instructables.com/id/Turn-your-

Raspberry-Pi-into-a-Portable-Bluetooth-A/

Page 6: 5.Playtime

Mayank Joneja

Auto E-Mail

Install SSMTP: Lightweight SMTP (Simple Mail Transfer

Protocol) server used to send e-mails

sudo apt-get install ssmtp

sudo apt-get install mailutils

Page 7: 5.Playtime

Mayank Joneja

Configurations

sudo nano /etc/ssmtp/ssmtp.conf

# Config file for sSMTP sendmail

#

# The person who gets all mail for userids < 1000

# Make this empty to disable rewriting.

root=postmaster

# The place where the mail goes. The actual machine name is required no

# MX records are consulted. Commonly mailhosts are named mail.domain.com

mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?#rewriteDomain=# The full hostnamehostname=Pi1

# Are users allowed to set their own From: address?# YES - Allow the user to specify their own From: address# NO - Use the system generated From: [email protected]=YourPassword#FromLineOverride=YESUseSTARTTLS=YESUseTLS=YES

Page 8: 5.Playtime

Mayank Joneja

Sending the mail

To send from terminal itself:

echo “Mail Body”| mail –s “Mail Subject” [email protected]

To include in a python script:

from subprocess import call

call(echo “Mail Body”| mail –s “Mail Subject” [email protected])

Page 9: 5.Playtime

Mayank Joneja

Running the Nokia 6610 LCD

http://botmayank.wordpress.com/2014/

06/24/running-the-nokia-6610-lcd-with-a-

raspberry-pi/

Page 10: 5.Playtime

Mayank Joneja

IR Remote using the Raspberry Pi

http://botmayank.wordpress.co

m/2014/07/08/ir-remote-for-

nikon-camera-using-the-

raspberry-pi-lirc/

Page 11: 5.Playtime

Mayank Joneja

Pi FM

http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter

http://www.instructables.com/id/Raspberry-Pi-Radio-Transmitter/

wget http://omattos.com/pifm.tar.gz

tar xvzf pifm.tar.gz

Write a script:

import PiFm

PiFm.play_sound(“filename.wav”)

Connect a 20cm or so plain wire to Pin 7 to act as an antenna

Tune an FM radio to 103.3Mhz

Page 12: 5.Playtime

Mayank Joneja

XBMC

XBMC is a free and open source media player developed by the XBMC Foundation, a non-profit technology consortium

It allows users to play and view most videos, music, such as podcasts from the internet, and all common digital media files from local and network storage media

XBMC for the Raspberry Pihttp://wiki.xbmc.org/?title=Raspberry_Pi

http://lifehacker.com/5929913/build-a-xbmc-media-center-with-a-35-raspberry-pi

Page 13: 5.Playtime

Mayank Joneja

IFTTT

IFTTT (If this then that) is a service that enables users to

connect different web applications (e.g., Facebook,

Evernote, Weather, Dropbox, etc.) together through simple

conditional statements known as "Recipes"

Use IFTTT on the Pi with email as a trigger

http://www.averagemanvsraspberrypi.com/2013/09/make-

your-raspberry-pi-tweet-its.html

http://mitchtech.net/connect-raspberry-pi-to-gmail-

facebook-twitter-more/

Page 14: 5.Playtime

Mayank Joneja

Streaming Live from a Webcam

http://jacobsalmela.com/raspberry-pi-

webcam-using-mjpg-streamer-over-internet

Page 15: 5.Playtime

Mayank Joneja

Hooking up a Relay!

A relay is a simple electro-mechanical switch which allows you to control 220V AC mains power supply based devices using the normal 5 or 12 V DC which is used by our microcontroller/microprocessor based system

In order to control the relay using a Raspberry Pi GPIO 3v3 pin, the easiest solution is to involve a transistor as an amplifier to boost both the voltage and the current

The connections are fairly straightforward and it ensures that there’s a certain level of isolation between the Pi and your AC Mains

http://raspberrypihobbyist.blogspot.in/2012/09/gpio-

output-relay-interface.html

Page 16: 5.Playtime

Mayank Joneja

RasPi Config

sudo raspi-config

Expand File System especially before sudo apt-get upgrade

Change hostname from raspberry if you want

Preferably change your password from “pi”

Expand root-fs

Page 17: 5.Playtime

Mayank Joneja

Updating the Firmware

While trying your hand at a lot of projects, sometimes, having the latest versions of

firmware and software packages is all you need i.e. the magic formula is:

sudo apt-get update

sudo apt-get upgradesudo rpi-update

Page 18: 5.Playtime

Mayank Joneja

Shell Scripting

http://www.penguintutor.com/raspberryp

i/basic-shell-programming-reference

Page 19: 5.Playtime

Mayank Joneja

Running Scripts on Boot

http://raspberrywebserver.com/serveradmin/run-a-script-on-start-up.html

2 easy ways of doing this:

1. Crontab:

sudo crontab -e

@reboot /home/pi/servoblaster/PiBits/ServoBlaster/user/servod

2. rc.local

sudo nano /etc/rc.local

Add “/home/pi/servoblaster/PiBits/ServoBlaster/user/servod &” at the end

(the ‘&’ runs it as a background process)

Page 20: 5.Playtime

Mayank Joneja

Wi-Fi Dongle Setup

http://www.maketecheasier.com/setup-wifi-on-raspberry-pi/

Page 21: 5.Playtime

Mayank Joneja

USB Internet Dongle

For Huawei E1731 Airtel connection:

http://saurorja.org/2013/03/30/airtel-3g-modem-e1731-linux-

configuration-complete-guide/

Most importantly,

sudo apt-get install usb-modeswitchand then,

http://www.geekride.com/huawei-e173-on-ubuntu/

Page 22: 5.Playtime

Mayank Joneja

Nearly Headless Nick Pi

http://inventrom.wordpress.com/2014/04/03/h

ow-to-access-shell-of-your-raspberry-pi-by-

datta_tech-for-inventrom/

Running your Pi Headless means running it

without a TV, Keyboard and Mouse

Page 23: 5.Playtime

Mayank Joneja

Raspberry Pi B+ !!

https://www.youtube.com/watch?v=0301dw18sXw

Page 24: 5.Playtime

Mayank Joneja

Wearables: Lilypad

http://arduino.cc/en/Main/arduinoBoardLilyPad

Page 25: 5.Playtime

Mayank Joneja

Resources

http://elinux.org/RPi_Tutorials

MagPi Magazine

inventrom.wordpress.com

botmayank.wordpress.com

http://www.raspberrypi.org/forums/

YouTube ! Raspberry Pi, BenHeck Show, RaspberryPiGuy, RaspberryPi4Beginners, Element14, Sparkfun, Geek Gurl Diaries, Alex Eames

https://learn.adafruit.com/category/learn-raspberry-pi

http://www.element14.com/community/community/raspberry-pi

http://raspberrypi.stackexchange.com/

www.instructables.com

www.makezine.com

www.thepihut.com

http://damnfineraspberrypi.com/

Page 26: 5.Playtime

Mayank Joneja

Buying Hardware and Accessories

http://www.crazypi.com/

http://www.onlinetps.com/ (General Electronics)

http://www.greenindiaelectronics.com/Raspberry-PI

In Delhi-Chandni Chowk - http://www.chandnichowknowonline.in/electronics-accessories

www.rhydolabz.com

www.sparkfun.com