SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

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
 

What's hot (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
 

Similar to 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
 

Similar to 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
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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)
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

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