SlideShare uma empresa Scribd logo
1 de 24
Raspberry Pi

       Frank Carver
      frankcarver.me
raspberryalphaomega.org.uk
•   ARM1176 CPU @700MHz
•   Broadcom BCM2835 chipset & GPU
•   512MB* RAM
•   USB, Ethernet, 1080p HDMI, audio
•   8 GPIO pins + UART, SPI, 12C
•   Storage on SD/SDHC Card
•   Linux, RiscOS etc. or “bare metal”

• About £25
Arduino Uno
•   ATmega328 CPU @16MHz
•   No GPU
•   32K Flash, 2K SRAM, 1K EEPROM
•   USB, no network or video
•   14 GPIO pins, 6 analogue inputs
•   No storage
•   “Bare metal” cross-compile only

• About £18
Cheap Dell PC
•   Intel CPU @2.8GHz
•   Intel HD GPU
•   2GB RAM
•   USB,Ethernet,SATA,HDMI,Wireless,…
•   No IO pins
•   500GB hard drive, DVD
•   Windows, Linux, etc.

• About £300
Software Development
Bare Metal               Linux
• Assembler              • Pretty much anything
• Cross-compiled C/C+    • Python
  + etc.                 • Ruby
• Hand-built languages   • Java
                         • perl
                         • PHP
                         • bash
                         • …
So let’s do some Ruby
So let’s do some Ruby
 Step 1: installation
So let’s do some Ruby
                     Step 1: installation

•   sudo apt-get install ruby1.9.3


                              That wasn’t so hard 
Ruby talks to hardware
File.open('/sys/class/gpio/export', 'w') { |file| file.write("17") }
File.open('/sys/class/gpio/gpio17/direction', 'w') { |file| file.write("out") }
File.open('/sys/class/gpio/export', 'w') { |file| file.write("27") }
File.open('/sys/class/gpio/gpio27/direction', 'w') { |file| file.write("out") }
File.open('/sys/class/gpio/export', 'w') { |file| file.write("22") }
File.open('/sys/class/gpio/gpio22/direction', 'w') { |file| file.write("out") }

begin

while true do
  for r in 0..1
    File.open('/sys/class/gpio/gpio17/value', 'w') { |file| file.write("#{r}") }
    for g in 0..1
      File.open('/sys/class/gpio/gpio27/value', 'w') { |file| file.write("#{g}") }
      for b in 0..1
        File.open('/sys/class/gpio/gpio22/value', 'w') { |file| file.write("#{b}") }
        sleep 1
      end
    end
  end
end

rescue SignalException
  File.open('/sys/class/gpio/gpio17/value', 'w') { |file| file.write("0") }
  File.open('/sys/class/gpio/gpio27/value', 'w') { |file| file.write("0") }
  File.open('/sys/class/gpio/gpio22/value', 'w') { |file| file.write("0") }
end
A nicer way
require "pi_piper"

pin_r = PiPiper::Pin.new(:pin => 17, :direction => :out)
pin_g = PiPiper::Pin.new(:pin => 27, :direction => :out)
pin_b = PiPiper::Pin.new(:pin => 22, :direction => :out)

begin

while true do
  for r in 0..1
    if r==1 ; pin_r.on else pin_r.off end
    for g in 0..1
      if g==1 ; pin_g.on else pin_g.off end
      for b in 0..1
        if b==1 ; pin_b.on else pin_b.off end
        sleep 1
      end
    end
  end
end

rescue SignalException
  pin_r.off
  pin_g.off
  pin_b.off
end
Another way
require "wiringpi"

io = WiringPi::GPIO.new(WPI_MODE_GPIO)

begin

while true do
  for r in 0..1
    io.write(17,r)
    for g in 0..1
      io.write(27,g)
      for b in 0..1
        io.write(22,b)
        sleep 1
      end
    end
  end
end

rescue SignalException
  io.write(17,0)
  io.write(27,0)
  io.write(22,0)
end
Input
require 'pi_piper'
include PiPiper

watch :pin => 23 do
  puts "Pin changed from #{last_value} to #{value}"
end

#Or

after :pin => 23, :goes => :high do
  puts "Button pressed"
end

PiPiper.wait
So what makes it special?
Raspberry Pi
is the gateway drug
 to microelectronics
More Fun – Ruby USB
•   wget http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-
    1.0.9/libusb-1.0.9.tar.bz2
•   tar xjf libusb-1.0.9.tar.bz2
•   cd libusb-1.0.9
•   ./configure
•   make
•   sudo make install

•   sudo apt-get install libusb-1.0-0-dev
•   sudo gem install libusb
Raspberry Pi for IPRUG

Mais conteúdo relacionado

Mais procurados

OpenBSD/sgi SMP implementation for Origin 350
OpenBSD/sgi SMP implementation for Origin 350OpenBSD/sgi SMP implementation for Origin 350
OpenBSD/sgi SMP implementation for Origin 350
Takuya ASADA
 

Mais procurados (20)

Introduction to nand2 tetris
Introduction to nand2 tetrisIntroduction to nand2 tetris
Introduction to nand2 tetris
 
Vm ware fuzzing - defcon russia 20
Vm ware fuzzing  - defcon russia 20Vm ware fuzzing  - defcon russia 20
Vm ware fuzzing - defcon russia 20
 
libuv: cross platform asynchronous i/o
libuv: cross platform asynchronous i/olibuv: cross platform asynchronous i/o
libuv: cross platform asynchronous i/o
 
OlinData Puppet Presentation for MOSC 2012
OlinData Puppet Presentation for MOSC 2012OlinData Puppet Presentation for MOSC 2012
OlinData Puppet Presentation for MOSC 2012
 
OpenBSD/sgi SMP implementation for Origin 350
OpenBSD/sgi SMP implementation for Origin 350OpenBSD/sgi SMP implementation for Origin 350
OpenBSD/sgi SMP implementation for Origin 350
 
SMP Implementation for OpenBSD/sgi [Japanese Edition]
SMP Implementation for OpenBSD/sgi [Japanese Edition]SMP Implementation for OpenBSD/sgi [Japanese Edition]
SMP Implementation for OpenBSD/sgi [Japanese Edition]
 
Intel IoT webinar #1 - Tedison presentation
Intel IoT webinar  #1 - Tedison presentation Intel IoT webinar  #1 - Tedison presentation
Intel IoT webinar #1 - Tedison presentation
 
Ctf hello,world!
Ctf hello,world! Ctf hello,world!
Ctf hello,world!
 
Custard pi 7 user information
Custard pi 7 user informationCustard pi 7 user information
Custard pi 7 user information
 
今日から始めるPlan 9 from Bell Labs
今日から始めるPlan 9 from Bell Labs今日から始めるPlan 9 from Bell Labs
今日から始めるPlan 9 from Bell Labs
 
Asphalt8.ifgiovanni
Asphalt8.ifgiovanniAsphalt8.ifgiovanni
Asphalt8.ifgiovanni
 
GCC
GCCGCC
GCC
 
Arduino and the real time web
Arduino and the real time webArduino and the real time web
Arduino and the real time web
 
Python with a SWIG of c++
Python with a  SWIG of c++Python with a  SWIG of c++
Python with a SWIG of c++
 
Internet Archive Video Presentation
Internet Archive Video Presentation Internet Archive Video Presentation
Internet Archive Video Presentation
 
Raspberry pi a la cfml
Raspberry pi a la cfmlRaspberry pi a la cfml
Raspberry pi a la cfml
 
GStreamer 101
GStreamer 101GStreamer 101
GStreamer 101
 
A deep dive into libuv
A deep dive into libuvA deep dive into libuv
A deep dive into libuv
 
Perl on embedded Linux with Buildroot‎
Perl on embedded Linux with Buildroot‎Perl on embedded Linux with Buildroot‎
Perl on embedded Linux with Buildroot‎
 
Overloading Perl OPs using XS
Overloading Perl OPs using XSOverloading Perl OPs using XS
Overloading Perl OPs using XS
 

Semelhante a Raspberry Pi for IPRUG

Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013
Tom Paulus
 
Exploring Raspberry Pi
Exploring Raspberry PiExploring Raspberry Pi
Exploring Raspberry Pi
Lentin Joseph
 
Intro to the raspberry pi board
Intro to the raspberry pi boardIntro to the raspberry pi board
Intro to the raspberry pi board
Thierry Gayet
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
ronnywang_tw
 

Semelhante a Raspberry Pi for IPRUG (20)

Presentazione
PresentazionePresentazione
Presentazione
 
Musiconlinux
MusiconlinuxMusiconlinux
Musiconlinux
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218
 
Internet of Things With PHP
Internet of Things With PHPInternet of Things With PHP
Internet of Things With PHP
 
manual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfmanual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdf
 
Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013
 
Raspberry Pi a la CFML
Raspberry Pi a la CFMLRaspberry Pi a la CFML
Raspberry Pi a la CFML
 
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
 
Exploring Raspberry Pi
Exploring Raspberry PiExploring Raspberry Pi
Exploring Raspberry Pi
 
Democratizing the Internet of Things
Democratizing the Internet of ThingsDemocratizing the Internet of Things
Democratizing the Internet of Things
 
Начало работы с Intel IoT Dev Kit
Начало работы с Intel IoT Dev KitНачало работы с Intel IoT Dev Kit
Начало работы с Intel IoT Dev Kit
 
Programming the Raspberry Pi element14
Programming the Raspberry Pi element14Programming the Raspberry Pi element14
Programming the Raspberry Pi element14
 
pcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFun
 
Raspberry Pi Using Python
Raspberry Pi Using PythonRaspberry Pi Using Python
Raspberry Pi Using Python
 
Senior Design: Raspberry Pi Cluster Computing
Senior Design: Raspberry Pi Cluster ComputingSenior Design: Raspberry Pi Cluster Computing
Senior Design: Raspberry Pi Cluster Computing
 
Python-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptxPython-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptx
 
Python on FreeBSD
Python on FreeBSDPython on FreeBSD
Python on FreeBSD
 
Up and running with Raspberry Pi
Up and running with Raspberry PiUp and running with Raspberry Pi
Up and running with Raspberry Pi
 
Intro to the raspberry pi board
Intro to the raspberry pi boardIntro to the raspberry pi board
Intro to the raspberry pi board
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Raspberry Pi for IPRUG

  • 1. Raspberry Pi Frank Carver frankcarver.me raspberryalphaomega.org.uk
  • 2.
  • 3.
  • 4. ARM1176 CPU @700MHz • Broadcom BCM2835 chipset & GPU • 512MB* RAM • USB, Ethernet, 1080p HDMI, audio • 8 GPIO pins + UART, SPI, 12C • Storage on SD/SDHC Card • Linux, RiscOS etc. or “bare metal” • About £25
  • 6. ATmega328 CPU @16MHz • No GPU • 32K Flash, 2K SRAM, 1K EEPROM • USB, no network or video • 14 GPIO pins, 6 analogue inputs • No storage • “Bare metal” cross-compile only • About £18
  • 8. Intel CPU @2.8GHz • Intel HD GPU • 2GB RAM • USB,Ethernet,SATA,HDMI,Wireless,… • No IO pins • 500GB hard drive, DVD • Windows, Linux, etc. • About £300
  • 9.
  • 10. Software Development Bare Metal Linux • Assembler • Pretty much anything • Cross-compiled C/C+ • Python + etc. • Ruby • Hand-built languages • Java • perl • PHP • bash • …
  • 11. So let’s do some Ruby
  • 12. So let’s do some Ruby Step 1: installation
  • 13. So let’s do some Ruby Step 1: installation • sudo apt-get install ruby1.9.3 That wasn’t so hard 
  • 14. Ruby talks to hardware File.open('/sys/class/gpio/export', 'w') { |file| file.write("17") } File.open('/sys/class/gpio/gpio17/direction', 'w') { |file| file.write("out") } File.open('/sys/class/gpio/export', 'w') { |file| file.write("27") } File.open('/sys/class/gpio/gpio27/direction', 'w') { |file| file.write("out") } File.open('/sys/class/gpio/export', 'w') { |file| file.write("22") } File.open('/sys/class/gpio/gpio22/direction', 'w') { |file| file.write("out") } begin while true do for r in 0..1 File.open('/sys/class/gpio/gpio17/value', 'w') { |file| file.write("#{r}") } for g in 0..1 File.open('/sys/class/gpio/gpio27/value', 'w') { |file| file.write("#{g}") } for b in 0..1 File.open('/sys/class/gpio/gpio22/value', 'w') { |file| file.write("#{b}") } sleep 1 end end end end rescue SignalException File.open('/sys/class/gpio/gpio17/value', 'w') { |file| file.write("0") } File.open('/sys/class/gpio/gpio27/value', 'w') { |file| file.write("0") } File.open('/sys/class/gpio/gpio22/value', 'w') { |file| file.write("0") } end
  • 15. A nicer way require "pi_piper" pin_r = PiPiper::Pin.new(:pin => 17, :direction => :out) pin_g = PiPiper::Pin.new(:pin => 27, :direction => :out) pin_b = PiPiper::Pin.new(:pin => 22, :direction => :out) begin while true do for r in 0..1 if r==1 ; pin_r.on else pin_r.off end for g in 0..1 if g==1 ; pin_g.on else pin_g.off end for b in 0..1 if b==1 ; pin_b.on else pin_b.off end sleep 1 end end end end rescue SignalException pin_r.off pin_g.off pin_b.off end
  • 16. Another way require "wiringpi" io = WiringPi::GPIO.new(WPI_MODE_GPIO) begin while true do for r in 0..1 io.write(17,r) for g in 0..1 io.write(27,g) for b in 0..1 io.write(22,b) sleep 1 end end end end rescue SignalException io.write(17,0) io.write(27,0) io.write(22,0) end
  • 17. Input require 'pi_piper' include PiPiper watch :pin => 23 do puts "Pin changed from #{last_value} to #{value}" end #Or after :pin => 23, :goes => :high do puts "Button pressed" end PiPiper.wait
  • 18. So what makes it special?
  • 19.
  • 20.
  • 21. Raspberry Pi is the gateway drug to microelectronics
  • 22.
  • 23. More Fun – Ruby USB • wget http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb- 1.0.9/libusb-1.0.9.tar.bz2 • tar xjf libusb-1.0.9.tar.bz2 • cd libusb-1.0.9 • ./configure • make • sudo make install • sudo apt-get install libusb-1.0-0-dev • sudo gem install libusb