Hardware hacking with ruby



Kerala Ruby User Meetup - January 2015


Hello, I am Akhil Stanislavose


 ✪  Works @ MobME Wireless ✪  
 ✪  Rubyist / JavaScript Maniac / Objective-C Noob ✪  
 ✪  TINKERER! ✪  


akhil.stanislavose@gmail.com
github.io/akhilstanislavose

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.


~ Wikipedia


Hardware Projects


making an LED glow
make it glow when a switch is pressed
make it blink
make it blink automatically?




    OK I NEED ELECTRONICS FOR THAT!

    FOR ME,



    HARD TO LEARN


    ResiStors, capacitors, diodes, transistors, integrated circuits and what not!

    Multivibrator, WTH?




    ABSTRACTION


    INTEGRATED CIRCUITS


    eg., multivibrator as a CHip, LIKE A LIBRARY.




    Microcontrollers

    programmable chips - better!

    Arduino


    Tinkering for everyone!


    C/C++

    no Ruby!

    But I want to do more


    Arduino is powerful, but not as powerful as a full blown computer.


    Raspberry Pi


    Full blown ARM computer running Linux!


    Runs Ruby!


    AMONG other popular programing environments C/C++, Java, Python, PHP etc.

    HELLO WORLD!

    
     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



    Blinken Window

    Inspired by Blinkenlights, Berlin

    Task



    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?


    IO EXPANDER

    SHIFT REGISTERS


    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!

    Made with Slides.com