Hardware hacking with ruby
Kerala Ruby User Meetup - January 2015
Hello, I am Akhil Stanislavose
✪ TINKERER! ✪
What is Hardware Hacking?
Building, rebuilding, modifying, and creating software, electronic hardware, either to make it better, faster, to give it added features or to make it do something it was not originally intended to do.
making an LED glow
make it glow when a switch is pressedmake it blinkmake it blink automatically?
OK I NEED ELECTRONICS FOR THAT!
HARD TO LEARN
ResiStors, capacitors, diodes, transistors, integrated circuits and what not!
eg., multivibrator as a CHip, LIKE A LIBRARY.
programmable chips - better!
Tinkering for everyone!
But I want to do more
Arduino is powerful, but not as powerful as a full blown computer.
Full blown ARM computer running Linux!
AMONG other popular programing environments C/C++, Java, Python, PHP etc.
require 'wiringpi' io = WiringPi::GPIO.new loop do io.write(1,HIGH) sleep(1) io.read(pin,LOW) sleep(1) end
Switch on an LED from any where
in the world?
require 'sinatra' require 'wiringpi' io = WiringPi::GPIO.new LED_PIN = 1 get '/on' do io.write(LED_PIN, HIGH) end get '/off' do io.write(LED_PIN, LOW) end
Inspired by Blinkenlights, Berlin
Control 60 leds with Pi
Should be easily programmable
Typical harware Project
DATA IN > PROCESS > DATA OUT
SENSORS > CONTROLLER > OUTPUT
PI > LED
Lets start by one LED
require 'wiringpi' class Led def initialize(pin) @pin = pin @io = WiringPi::GPIO.new end def on @io.write(@pin, HIGH) end def off @io.write(@pin, LOW) end end
Only 17 GPIO pins
What about other 43 LEDs?
Serial to Parallel Converter
8bit shift register = 8 pin IO Expander
8 Cascaded 8bit shift regsiter = 64 pin IO Expander
WHY YOU SHOULD TRY HARDWARE?
THE END. THANKS!
Hardware Hacking With Ruby
By akhil stanislavose