SlideShare uma empresa Scribd logo
1 de 25
Python in Raspberry Pi
Sudar Muthu (@sudarmuthu)
http://github.com/sudar
http://hardwarefun.com
I love Python ;)
Credit Card Sized
Computer
Basic Electronics
http://en.wikipedia.org/wiki/File:OhmsLaw.svg
GPIO Pins
http://learn.adafruit.com/assets/3052
Setup Python
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio
Set the status of GPIO Pins
https://github.com/sudar/raspberry-pi-sketches/blob/master/led-blink/led-blink.py
Set the status of GPIO Pins
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)
try:
while True:
GPIO.output(12, GPIO.HIGH)
time.sleep(1)
GPIO.output(12, GPIO.LOW)
time.sleep(1)
finally:
GPIO.cleanup()
https://github.com/sudar/raspberry-pi-sketches/blob/master/led-blink/led-blink.py
Demo
Let there be Light
https://github.com/sudar/raspberry-pi-sketches/blob/master/led-blink/led-blink.py
Changing the brightness of the LED
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)
p = GPIO.PWM(12, 50) # channel=12 frequency=50Hz
p.start(0)
try:
while True:
for dc in range(0, 101, 5):
p.ChangeDutyCycle(dc)
time.sleep(0.1)
for dc in range(100, -1, -5):
p.ChangeDutyCycle(dc)
time.sleep(0.1)
finally:
p.stop()
GPIO.cleanup()
https://github.com/sudar/raspberry-pi-sketches/blob/master/led-blink/pwm.py
Demo
Can you see the brightness changing?
https://github.com/sudar/raspberry-pi-sketches/blob/master/led-blink/pwm.py
Reading the status of the Pin
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
try:
while True:
if GPIO.input(11):
print "Button is on"
else:
print "Button is off"
time.sleep(0.1)
finally:
GPIO.cleanup()
https://github.com/sudar/raspberry-pi-sketches/blob/master/button-input/button-input.py
Reading the status of the Pin
https://github.com/sudar/raspberry-pi-sketches/blob/master/button-input/button-input.py
Demo
What happens when the button is pressed?
https://github.com/sudar/raspberry-pi-sketches/blob/master/button-input/button-input.py
Combining Input and Output
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(12, GPIO.OUT)
try:
while True:
if GPIO.input(11):
print "Button is on"
GPIO.output(12, 1)
else:
GPIO.output(12, 0)
time.sleep(0.1)
finally:
GPIO.cleanup()
https://github.com/sudar/raspberry-pi-sketches/blob/master/button-and-led/button-and-led.py
Combining Input and Output
https://github.com/sudar/raspberry-pi-sketches/blob/master/button-and-led/button-and-led.py
Demo
Let’s control the LED by pressing the button
https://github.com/sudar/raspberry-pi-sketches/blob/master/button-and-led/button-and-led.py
What more can be done?
More protocols
• I2C
• SPI
• Serial
Interacting with webcam
• “PyGame” provides easy interface
• Can get fancy using “opencv”
• Both USB and GPIO interface are supported
Distributed Computing
• Each Pi can be used as cheap node
• Form grids using a cluster of Pi’s
• Can share CPU, memory and disk space
http://www.cl.cam.ac.uk/projects/raspberrypi/t
utorials/distributed-computing/
Limitations
• No built-in Analog to Digital support
• Can’t run Inductive load (motors)
• Is not real-time (CPU might be busy)
• No “safe circuits” present
• Operates at 3.3V and is not directly
compatible with Arduino voltage
Best of two worlds
http://learn.adafruit.com/assets/3199 http://learn.adafruit.com/assets/2123
Links
• Source code -
https://github.com/sudar/raspberry-pi-sketches/
• My blog - http://hardwarefun.com
• Python GPIO -
https://code.google.com/p/raspberry-gpio-
python/
• Distributed computing using Pi -
http://www.cl.cam.ac.uk/projects/raspberrypi/tu
torials/distributed-computing/
Thank you
Sudar Muthu
http://hardwarefun.com

Mais conteúdo relacionado

Mais procurados

Raspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioRaspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioKevin Hooke
 
Raspberry Pi and Amateur Radio - 2020 update
Raspberry Pi and Amateur Radio - 2020 updateRaspberry Pi and Amateur Radio - 2020 update
Raspberry Pi and Amateur Radio - 2020 updateKevin Hooke
 
Single Board Computers & Raspberry Pi Basics
Single Board Computers & Raspberry Pi BasicsSingle Board Computers & Raspberry Pi Basics
Single Board Computers & Raspberry Pi BasicsEueung Mulyana
 
Interfacing the Raspberry Pi to the World
Interfacing the Raspberry Pi to the WorldInterfacing the Raspberry Pi to the World
Interfacing the Raspberry Pi to the WorldOmer Kilic
 
Building the Internet of Things with Raspberry Pi
Building the Internet of Things with Raspberry PiBuilding the Internet of Things with Raspberry Pi
Building the Internet of Things with Raspberry PiNeil Broers
 
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game ConsoleRaspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game ConsoleRICELEEIO
 
Introduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIOIntroduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIOKris Findlay
 
Getting Started with Raspberry Pi and Arduino
Getting Started with Raspberry Pi and ArduinoGetting Started with Raspberry Pi and Arduino
Getting Started with Raspberry Pi and ArduinoChad Mairn
 
IOT Talking to Webserver - how to
IOT Talking to Webserver - how to IOT Talking to Webserver - how to
IOT Talking to Webserver - how to Indraneel Ganguli
 
Micropython on MicroControllers
Micropython on MicroControllersMicropython on MicroControllers
Micropython on MicroControllersAkshai M
 
Getting Started with MicroPython and LoPy
Getting Started with MicroPython and LoPyGetting Started with MicroPython and LoPy
Getting Started with MicroPython and LoPyChristian Fässler
 
DigiPinguïns: demo Raspberry Pi (Koen De Smet)
DigiPinguïns: demo Raspberry Pi (Koen De Smet)DigiPinguïns: demo Raspberry Pi (Koen De Smet)
DigiPinguïns: demo Raspberry Pi (Koen De Smet)Avansa Mid- en Zuidwest
 
Micropython for the iot
Micropython for the iotMicropython for the iot
Micropython for the iotJacques Supcik
 
Controlling the internet of things using wearable tech - Design+Code Day; Ara...
Controlling the internet of things using wearable tech - Design+Code Day; Ara...Controlling the internet of things using wearable tech - Design+Code Day; Ara...
Controlling the internet of things using wearable tech - Design+Code Day; Ara...ArabNet ME
 
Wi-Fi Modem For the Commodore 64
Wi-Fi Modem For the Commodore 64Wi-Fi Modem For the Commodore 64
Wi-Fi Modem For the Commodore 64Leif Bloomquist
 
Security System with PIR sensor and Raspberry Pi
Security System with PIR sensor and Raspberry PiSecurity System with PIR sensor and Raspberry Pi
Security System with PIR sensor and Raspberry PiRaúl Peláez Berroteran
 

Mais procurados (19)

Prototipare col raspberry pi
Prototipare col raspberry piPrototipare col raspberry pi
Prototipare col raspberry pi
 
Raspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioRaspberry Pi and Amateur Radio
Raspberry Pi and Amateur Radio
 
Raspberry Pi and Amateur Radio - 2020 update
Raspberry Pi and Amateur Radio - 2020 updateRaspberry Pi and Amateur Radio - 2020 update
Raspberry Pi and Amateur Radio - 2020 update
 
Single Board Computers & Raspberry Pi Basics
Single Board Computers & Raspberry Pi BasicsSingle Board Computers & Raspberry Pi Basics
Single Board Computers & Raspberry Pi Basics
 
Interfacing the Raspberry Pi to the World
Interfacing the Raspberry Pi to the WorldInterfacing the Raspberry Pi to the World
Interfacing the Raspberry Pi to the World
 
Building the Internet of Things with Raspberry Pi
Building the Internet of Things with Raspberry PiBuilding the Internet of Things with Raspberry Pi
Building the Internet of Things with Raspberry Pi
 
Meng
MengMeng
Meng
 
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game ConsoleRaspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
 
Introduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIOIntroduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIO
 
Getting Started with Raspberry Pi and Arduino
Getting Started with Raspberry Pi and ArduinoGetting Started with Raspberry Pi and Arduino
Getting Started with Raspberry Pi and Arduino
 
IOT Talking to Webserver - how to
IOT Talking to Webserver - how to IOT Talking to Webserver - how to
IOT Talking to Webserver - how to
 
Micropython on MicroControllers
Micropython on MicroControllersMicropython on MicroControllers
Micropython on MicroControllers
 
Getting Started with MicroPython and LoPy
Getting Started with MicroPython and LoPyGetting Started with MicroPython and LoPy
Getting Started with MicroPython and LoPy
 
DigiPinguïns: demo Raspberry Pi (Koen De Smet)
DigiPinguïns: demo Raspberry Pi (Koen De Smet)DigiPinguïns: demo Raspberry Pi (Koen De Smet)
DigiPinguïns: demo Raspberry Pi (Koen De Smet)
 
Micropython for the iot
Micropython for the iotMicropython for the iot
Micropython for the iot
 
Controlling the internet of things using wearable tech - Design+Code Day; Ara...
Controlling the internet of things using wearable tech - Design+Code Day; Ara...Controlling the internet of things using wearable tech - Design+Code Day; Ara...
Controlling the internet of things using wearable tech - Design+Code Day; Ara...
 
Rassberry pi
Rassberry piRassberry pi
Rassberry pi
 
Wi-Fi Modem For the Commodore 64
Wi-Fi Modem For the Commodore 64Wi-Fi Modem For the Commodore 64
Wi-Fi Modem For the Commodore 64
 
Security System with PIR sensor and Raspberry Pi
Security System with PIR sensor and Raspberry PiSecurity System with PIR sensor and Raspberry Pi
Security System with PIR sensor and Raspberry Pi
 

Destaque

Getting started with arduino workshop
Getting started with arduino workshopGetting started with arduino workshop
Getting started with arduino workshopSudar Muthu
 
Raspberrypi best ppt
Raspberrypi best ppt Raspberrypi best ppt
Raspberrypi best ppt SOMRAJ GAUTAM
 
Connect all your customers on one multichannel platform!
Connect all your customers on one multichannel platform!Connect all your customers on one multichannel platform!
Connect all your customers on one multichannel platform!Slawomir Kluczewski
 
20 C programs
20 C programs20 C programs
20 C programsnavjoth
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial javaTpoint s
 
Conditional Loops Python
Conditional Loops PythonConditional Loops Python
Conditional Loops Pythonprimeteacher32
 
Cloud Computing to Internet of Things
Cloud Computing to Internet of ThingsCloud Computing to Internet of Things
Cloud Computing to Internet of ThingsHermesDDS
 
Socket Programming In Python
Socket Programming In PythonSocket Programming In Python
Socket Programming In Pythondidip
 
Got Python I/O: IoT Develoment in Python via GPIO
Got Python I/O: IoT Develoment in Python via GPIOGot Python I/O: IoT Develoment in Python via GPIO
Got Python I/O: IoT Develoment in Python via GPIOAdam Englander
 
Internet of Things for Libraries
Internet of Things for LibrariesInternet of Things for Libraries
Internet of Things for LibrariesNicole Baratta
 
Using arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of thingsUsing arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of thingsSudar Muthu
 
C programs
C programsC programs
C programsMinu S
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in CSmit Parikh
 
Arduino Robotics workshop day2
Arduino Robotics workshop day2Arduino Robotics workshop day2
Arduino Robotics workshop day2Sudar Muthu
 
Mastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsMastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsRuth Marvin
 
Arduino Robotics workshop Day1
Arduino Robotics workshop Day1Arduino Robotics workshop Day1
Arduino Robotics workshop Day1Sudar Muthu
 
[Slides] Customer Experience in the Internet of Things by Altimeter Group
[Slides] Customer Experience in the Internet of Things by Altimeter Group[Slides] Customer Experience in the Internet of Things by Altimeter Group
[Slides] Customer Experience in the Internet of Things by Altimeter GroupAltimeter, a Prophet Company
 

Destaque (20)

Getting started with arduino workshop
Getting started with arduino workshopGetting started with arduino workshop
Getting started with arduino workshop
 
Raspberrypi best ppt
Raspberrypi best ppt Raspberrypi best ppt
Raspberrypi best ppt
 
Connect all your customers on one multichannel platform!
Connect all your customers on one multichannel platform!Connect all your customers on one multichannel platform!
Connect all your customers on one multichannel platform!
 
20 C programs
20 C programs20 C programs
20 C programs
 
Computer Logic
Computer LogicComputer Logic
Computer Logic
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
Conditional Loops Python
Conditional Loops PythonConditional Loops Python
Conditional Loops Python
 
Loops in c
Loops in cLoops in c
Loops in c
 
Cloud Computing to Internet of Things
Cloud Computing to Internet of ThingsCloud Computing to Internet of Things
Cloud Computing to Internet of Things
 
Socket Programming In Python
Socket Programming In PythonSocket Programming In Python
Socket Programming In Python
 
Got Python I/O: IoT Develoment in Python via GPIO
Got Python I/O: IoT Develoment in Python via GPIOGot Python I/O: IoT Develoment in Python via GPIO
Got Python I/O: IoT Develoment in Python via GPIO
 
CS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUALCS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUAL
 
Internet of Things for Libraries
Internet of Things for LibrariesInternet of Things for Libraries
Internet of Things for Libraries
 
Using arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of thingsUsing arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of things
 
C programs
C programsC programs
C programs
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in C
 
Arduino Robotics workshop day2
Arduino Robotics workshop day2Arduino Robotics workshop day2
Arduino Robotics workshop day2
 
Mastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsMastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loops
 
Arduino Robotics workshop Day1
Arduino Robotics workshop Day1Arduino Robotics workshop Day1
Arduino Robotics workshop Day1
 
[Slides] Customer Experience in the Internet of Things by Altimeter Group
[Slides] Customer Experience in the Internet of Things by Altimeter Group[Slides] Customer Experience in the Internet of Things by Altimeter Group
[Slides] Customer Experience in the Internet of Things by Altimeter Group
 

Semelhante a Control LED with Python on Raspberry Pi

manual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfmanual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfssuserc5ee4c
 
Module Workshop NSC "Raspberry pi3 with Python" - Sanusi & Sasmitoh RR
Module Workshop NSC "Raspberry pi3 with Python" - Sanusi & Sasmitoh RRModule Workshop NSC "Raspberry pi3 with Python" - Sanusi & Sasmitoh RR
Module Workshop NSC "Raspberry pi3 with Python" - Sanusi & Sasmitoh RRSasmitoh Rahmad Riady
 
Hands on Raspberry Pi - Creative Technologists
Hands on Raspberry Pi - Creative TechnologistsHands on Raspberry Pi - Creative Technologists
Hands on Raspberry Pi - Creative Technologistsbennuttall
 
Startup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django sessionStartup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django sessionJuraj Michálek
 
AWS ロボを作ろう JAWSUG Kobe
AWS ロボを作ろう JAWSUG KobeAWS ロボを作ろう JAWSUG Kobe
AWS ロボを作ろう JAWSUG Kobe崇之 清水
 
Embedded Rust and more
Embedded Rust and moreEmbedded Rust and more
Embedded Rust and moreKiwamu Okabe
 
Raspberry pi lcd-shield20x4
Raspberry pi lcd-shield20x4Raspberry pi lcd-shield20x4
Raspberry pi lcd-shield20x4Iulius Bors
 
Chromium Sandbox on Linux (BlackHoodie 2018)
Chromium Sandbox on Linux (BlackHoodie 2018)Chromium Sandbox on Linux (BlackHoodie 2018)
Chromium Sandbox on Linux (BlackHoodie 2018)Patricia Aas
 
Princeton Wintersession: Software Quality Assurance Tooling
Princeton Wintersession: Software Quality Assurance ToolingPrinceton Wintersession: Software Quality Assurance Tooling
Princeton Wintersession: Software Quality Assurance ToolingHenry Schreiner
 
Swift hardware hacking @ try! Swift
Swift hardware hacking @ try! SwiftSwift hardware hacking @ try! Swift
Swift hardware hacking @ try! SwiftSally Shepard
 
Interfacing two wire adc0831 to raspberry pi2 / Pi3
Interfacing two wire adc0831 to raspberry pi2 / Pi3Interfacing two wire adc0831 to raspberry pi2 / Pi3
Interfacing two wire adc0831 to raspberry pi2 / Pi3Dnyanesh Patil
 
Project ACRN GPIO mediator introduction
Project ACRN GPIO mediator introductionProject ACRN GPIO mediator introduction
Project ACRN GPIO mediator introductionProject ACRN
 
Linux Security APIs and the Chromium Sandbox
Linux Security APIs and the Chromium SandboxLinux Security APIs and the Chromium Sandbox
Linux Security APIs and the Chromium SandboxPatricia Aas
 
IOT in HEALTH CARE .pptx
IOT in HEALTH CARE .pptxIOT in HEALTH CARE .pptx
IOT in HEALTH CARE .pptxajeynagar6
 

Semelhante a Control LED with Python on Raspberry Pi (20)

manual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfmanual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdf
 
Module Workshop NSC "Raspberry pi3 with Python" - Sanusi & Sasmitoh RR
Module Workshop NSC "Raspberry pi3 with Python" - Sanusi & Sasmitoh RRModule Workshop NSC "Raspberry pi3 with Python" - Sanusi & Sasmitoh RR
Module Workshop NSC "Raspberry pi3 with Python" - Sanusi & Sasmitoh RR
 
Hands on Raspberry Pi - Creative Technologists
Hands on Raspberry Pi - Creative TechnologistsHands on Raspberry Pi - Creative Technologists
Hands on Raspberry Pi - Creative Technologists
 
Startup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django sessionStartup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django session
 
AWS ロボを作ろう JAWSUG Kobe
AWS ロボを作ろう JAWSUG KobeAWS ロボを作ろう JAWSUG Kobe
AWS ロボを作ろう JAWSUG Kobe
 
Embedded Rust and more
Embedded Rust and moreEmbedded Rust and more
Embedded Rust and more
 
Raspberry pi lcd-shield20x4
Raspberry pi lcd-shield20x4Raspberry pi lcd-shield20x4
Raspberry pi lcd-shield20x4
 
Chromium Sandbox on Linux (BlackHoodie 2018)
Chromium Sandbox on Linux (BlackHoodie 2018)Chromium Sandbox on Linux (BlackHoodie 2018)
Chromium Sandbox on Linux (BlackHoodie 2018)
 
Princeton Wintersession: Software Quality Assurance Tooling
Princeton Wintersession: Software Quality Assurance ToolingPrinceton Wintersession: Software Quality Assurance Tooling
Princeton Wintersession: Software Quality Assurance Tooling
 
Swift hardware hacking @ try! Swift
Swift hardware hacking @ try! SwiftSwift hardware hacking @ try! Swift
Swift hardware hacking @ try! Swift
 
Interfacing two wire adc0831 to raspberry pi2 / Pi3
Interfacing two wire adc0831 to raspberry pi2 / Pi3Interfacing two wire adc0831 to raspberry pi2 / Pi3
Interfacing two wire adc0831 to raspberry pi2 / Pi3
 
Hom Class
Hom ClassHom Class
Hom Class
 
Hom Class
Hom ClassHom Class
Hom Class
 
Hom Class
Hom ClassHom Class
Hom Class
 
Project ACRN GPIO mediator introduction
Project ACRN GPIO mediator introductionProject ACRN GPIO mediator introduction
Project ACRN GPIO mediator introduction
 
Meng
MengMeng
Meng
 
Atomic pi Mini PC
Atomic pi Mini PCAtomic pi Mini PC
Atomic pi Mini PC
 
Atomic PI apug
Atomic PI apugAtomic PI apug
Atomic PI apug
 
Linux Security APIs and the Chromium Sandbox
Linux Security APIs and the Chromium SandboxLinux Security APIs and the Chromium Sandbox
Linux Security APIs and the Chromium Sandbox
 
IOT in HEALTH CARE .pptx
IOT in HEALTH CARE .pptxIOT in HEALTH CARE .pptx
IOT in HEALTH CARE .pptx
 

Mais de Sudar Muthu

A quick preview of WP CLI - Chennai WordPress Meetup
A quick preview of WP CLI - Chennai WordPress MeetupA quick preview of WP CLI - Chennai WordPress Meetup
A quick preview of WP CLI - Chennai WordPress MeetupSudar Muthu
 
WordPress Developer tools
WordPress Developer toolsWordPress Developer tools
WordPress Developer toolsSudar Muthu
 
WordPress Developer Tools to increase productivity
WordPress Developer Tools to increase productivityWordPress Developer Tools to increase productivity
WordPress Developer Tools to increase productivitySudar Muthu
 
Unit testing for WordPress
Unit testing for WordPressUnit testing for WordPress
Unit testing for WordPressSudar Muthu
 
Unit testing in php
Unit testing in phpUnit testing in php
Unit testing in phpSudar Muthu
 
How arduino helped me in life
How arduino helped me in lifeHow arduino helped me in life
How arduino helped me in lifeSudar Muthu
 
Having fun with hardware
Having fun with hardwareHaving fun with hardware
Having fun with hardwareSudar Muthu
 
Hack 101 at IIT Kanpur
Hack 101 at IIT KanpurHack 101 at IIT Kanpur
Hack 101 at IIT KanpurSudar Muthu
 
PureCSS open hack 2013
PureCSS open hack 2013PureCSS open hack 2013
PureCSS open hack 2013Sudar Muthu
 
Hands on Hadoop and pig
Hands on Hadoop and pigHands on Hadoop and pig
Hands on Hadoop and pigSudar Muthu
 
Lets make robots
Lets make robotsLets make robots
Lets make robotsSudar Muthu
 
Capabilities of Arduino (including Due)
Capabilities of Arduino (including Due)Capabilities of Arduino (including Due)
Capabilities of Arduino (including Due)Sudar Muthu
 
Controlling robots using javascript
Controlling robots using javascriptControlling robots using javascript
Controlling robots using javascriptSudar Muthu
 
Picture perfect hacks with flickr API
Picture perfect hacks with flickr APIPicture perfect hacks with flickr API
Picture perfect hacks with flickr APISudar Muthu
 
Capabilities of Arduino
Capabilities of ArduinoCapabilities of Arduino
Capabilities of ArduinoSudar Muthu
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDDSudar Muthu
 
Using Javascript in today's world
Using Javascript in today's worldUsing Javascript in today's world
Using Javascript in today's worldSudar Muthu
 
Hack u yql-iit-delhi
Hack u yql-iit-delhiHack u yql-iit-delhi
Hack u yql-iit-delhiSudar Muthu
 

Mais de Sudar Muthu (20)

A quick preview of WP CLI - Chennai WordPress Meetup
A quick preview of WP CLI - Chennai WordPress MeetupA quick preview of WP CLI - Chennai WordPress Meetup
A quick preview of WP CLI - Chennai WordPress Meetup
 
WordPress Developer tools
WordPress Developer toolsWordPress Developer tools
WordPress Developer tools
 
WordPress Developer Tools to increase productivity
WordPress Developer Tools to increase productivityWordPress Developer Tools to increase productivity
WordPress Developer Tools to increase productivity
 
Unit testing for WordPress
Unit testing for WordPressUnit testing for WordPress
Unit testing for WordPress
 
Unit testing in php
Unit testing in phpUnit testing in php
Unit testing in php
 
How arduino helped me in life
How arduino helped me in lifeHow arduino helped me in life
How arduino helped me in life
 
Having fun with hardware
Having fun with hardwareHaving fun with hardware
Having fun with hardware
 
Hack 101 at IIT Kanpur
Hack 101 at IIT KanpurHack 101 at IIT Kanpur
Hack 101 at IIT Kanpur
 
PureCSS open hack 2013
PureCSS open hack 2013PureCSS open hack 2013
PureCSS open hack 2013
 
Pig workshop
Pig workshopPig workshop
Pig workshop
 
Hands on Hadoop and pig
Hands on Hadoop and pigHands on Hadoop and pig
Hands on Hadoop and pig
 
Lets make robots
Lets make robotsLets make robots
Lets make robots
 
Capabilities of Arduino (including Due)
Capabilities of Arduino (including Due)Capabilities of Arduino (including Due)
Capabilities of Arduino (including Due)
 
Controlling robots using javascript
Controlling robots using javascriptControlling robots using javascript
Controlling robots using javascript
 
Picture perfect hacks with flickr API
Picture perfect hacks with flickr APIPicture perfect hacks with flickr API
Picture perfect hacks with flickr API
 
Hacking 101
Hacking 101Hacking 101
Hacking 101
 
Capabilities of Arduino
Capabilities of ArduinoCapabilities of Arduino
Capabilities of Arduino
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
 
Using Javascript in today's world
Using Javascript in today's worldUsing Javascript in today's world
Using Javascript in today's world
 
Hack u yql-iit-delhi
Hack u yql-iit-delhiHack u yql-iit-delhi
Hack u yql-iit-delhi
 

Último

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Último (20)

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Control LED with Python on Raspberry Pi

  • 1. Python in Raspberry Pi Sudar Muthu (@sudarmuthu) http://github.com/sudar http://hardwarefun.com
  • 6. Setup Python sudo apt-get install python-dev sudo apt-get install python-rpi.gpio
  • 7. Set the status of GPIO Pins https://github.com/sudar/raspberry-pi-sketches/blob/master/led-blink/led-blink.py
  • 8. Set the status of GPIO Pins import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(12, GPIO.OUT) try: while True: GPIO.output(12, GPIO.HIGH) time.sleep(1) GPIO.output(12, GPIO.LOW) time.sleep(1) finally: GPIO.cleanup() https://github.com/sudar/raspberry-pi-sketches/blob/master/led-blink/led-blink.py
  • 9. Demo Let there be Light https://github.com/sudar/raspberry-pi-sketches/blob/master/led-blink/led-blink.py
  • 10. Changing the brightness of the LED import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(12, GPIO.OUT) p = GPIO.PWM(12, 50) # channel=12 frequency=50Hz p.start(0) try: while True: for dc in range(0, 101, 5): p.ChangeDutyCycle(dc) time.sleep(0.1) for dc in range(100, -1, -5): p.ChangeDutyCycle(dc) time.sleep(0.1) finally: p.stop() GPIO.cleanup() https://github.com/sudar/raspberry-pi-sketches/blob/master/led-blink/pwm.py
  • 11. Demo Can you see the brightness changing? https://github.com/sudar/raspberry-pi-sketches/blob/master/led-blink/pwm.py
  • 12. Reading the status of the Pin import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) try: while True: if GPIO.input(11): print "Button is on" else: print "Button is off" time.sleep(0.1) finally: GPIO.cleanup() https://github.com/sudar/raspberry-pi-sketches/blob/master/button-input/button-input.py
  • 13. Reading the status of the Pin https://github.com/sudar/raspberry-pi-sketches/blob/master/button-input/button-input.py
  • 14. Demo What happens when the button is pressed? https://github.com/sudar/raspberry-pi-sketches/blob/master/button-input/button-input.py
  • 15. Combining Input and Output import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(12, GPIO.OUT) try: while True: if GPIO.input(11): print "Button is on" GPIO.output(12, 1) else: GPIO.output(12, 0) time.sleep(0.1) finally: GPIO.cleanup() https://github.com/sudar/raspberry-pi-sketches/blob/master/button-and-led/button-and-led.py
  • 16. Combining Input and Output https://github.com/sudar/raspberry-pi-sketches/blob/master/button-and-led/button-and-led.py
  • 17. Demo Let’s control the LED by pressing the button https://github.com/sudar/raspberry-pi-sketches/blob/master/button-and-led/button-and-led.py
  • 18. What more can be done?
  • 19. More protocols • I2C • SPI • Serial
  • 20. Interacting with webcam • “PyGame” provides easy interface • Can get fancy using “opencv” • Both USB and GPIO interface are supported
  • 21. Distributed Computing • Each Pi can be used as cheap node • Form grids using a cluster of Pi’s • Can share CPU, memory and disk space http://www.cl.cam.ac.uk/projects/raspberrypi/t utorials/distributed-computing/
  • 22. Limitations • No built-in Analog to Digital support • Can’t run Inductive load (motors) • Is not real-time (CPU might be busy) • No “safe circuits” present • Operates at 3.3V and is not directly compatible with Arduino voltage
  • 23. Best of two worlds http://learn.adafruit.com/assets/3199 http://learn.adafruit.com/assets/2123
  • 24. Links • Source code - https://github.com/sudar/raspberry-pi-sketches/ • My blog - http://hardwarefun.com • Python GPIO - https://code.google.com/p/raspberry-gpio- python/ • Distributed computing using Pi - http://www.cl.cam.ac.uk/projects/raspberrypi/tu torials/distributed-computing/