Raspberry Pi       Frank Carver      frankcarver.meraspberryalphaomega.org.uk
•   ARM1176 CPU @700MHz•   Broadcom BCM2835 chipset & GPU•   512MB* RAM•   USB, Ethernet, 1080p HDMI, audio•   8 GPIO pins...
Arduino Uno
•   ATmega328 CPU @16MHz•   No GPU•   32K Flash, 2K SRAM, 1K EEPROM•   USB, no network or video•   14 GPIO pins, 6 analogu...
Cheap Dell PC
•   Intel CPU @2.8GHz•   Intel HD GPU•   2GB RAM•   USB,Ethernet,SATA,HDMI,Wireless,…•   No IO pins•   500GB hard drive, D...
Software DevelopmentBare Metal               Linux• Assembler              • Pretty much anything• Cross-compiled C/C+    ...
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                          ...
Ruby talks to hardwareFile.open(/sys/class/gpio/export, w) { |file| file.write("17") }File.open(/sys/class/gpio/gpio17/dir...
A nicer wayrequire "pi_piper"pin_r = PiPiper::Pin.new(:pin => 17, :direction => :out)pin_g = PiPiper::Pin.new(:pin => 27, ...
Another wayrequire "wiringpi"io = WiringPi::GPIO.new(WPI_MODE_GPIO)beginwhile true do  for r in 0..1    io.write(17,r)    ...
Inputrequire pi_piperinclude PiPiperwatch :pin => 23 do  puts "Pin changed from #{last_value} to #{value}"end#Orafter :pin...
So what makes it special?
Raspberry Piis 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•...
Raspberry Pi for IPRUG
Raspberry Pi for IPRUG
Raspberry Pi for IPRUG
Raspberry Pi for IPRUG
Raspberry Pi for IPRUG
Raspberry Pi for IPRUG
Raspberry Pi for IPRUG
Upcoming SlideShare
Loading in...5
×

Raspberry Pi for IPRUG

932

Published on

A short talk about the Raspberry Pi for the Ipswich Ruby User Group

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
932
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Raspberry Pi for IPRUG

  1. 1. Raspberry Pi Frank Carver frankcarver.meraspberryalphaomega.org.uk
  2. 2. • 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
  3. 3. Arduino Uno
  4. 4. • 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
  5. 5. Cheap Dell PC
  6. 6. • 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
  7. 7. Software DevelopmentBare Metal Linux• Assembler • Pretty much anything• Cross-compiled C/C+ • Python + etc. • Ruby• Hand-built languages • Java • perl • PHP • bash • …
  8. 8. So let’s do some Ruby
  9. 9. So let’s do some Ruby Step 1: installation
  10. 10. So let’s do some Ruby Step 1: installation• sudo apt-get install ruby1.9.3 That wasn’t so hard 
  11. 11. Ruby talks to hardwareFile.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") }beginwhile 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 endendrescue 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
  12. 12. A nicer wayrequire "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)beginwhile 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 endendrescue SignalException pin_r.off pin_g.off pin_b.offend
  13. 13. Another wayrequire "wiringpi"io = WiringPi::GPIO.new(WPI_MODE_GPIO)beginwhile 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 endendrescue SignalException io.write(17,0) io.write(27,0) io.write(22,0)end
  14. 14. Inputrequire pi_piperinclude PiPiperwatch :pin => 23 do puts "Pin changed from #{last_value} to #{value}"end#Orafter :pin => 23, :goes => :high do puts "Button pressed"endPiPiper.wait
  15. 15. So what makes it special?
  16. 16. Raspberry Piis the gateway drug to microelectronics
  17. 17. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×