Arduino the ruby_way
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Arduino the ruby_way

on

  • 659 views

Writing software is great, websites, applications, and scripts are things we interact with every day. What about writing software that we can interact with in the physical world? From automated ...

Writing software is great, websites, applications, and scripts are things we interact with every day. What about writing software that we can interact with in the physical world? From automated sprinkler systems that turn off when you pull into your drive way, to scoreboards at the company foosball table physical computing opens a door for the innovator inside every software engineer.
It's too hard
Not true, there are amazing libraries and compilers that let us write software for Arduinos in the best language, Ruby. Think about it no C, no headers, and no static types, just plain old ruby. That is a good deal.

In this talk I will go over a few of the most popular Ruby libraries for interacting with an Arduino, talk about some basics of each library and then spend time on how these libraries and Arduino can interact to create applications that respond in the physical world. There will be t-shirts shot from a robotic cannon.

Statistics

Views

Total Views
659
Views on SlideShare
659
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Arduino the ruby_way Presentation Transcript

  • 1. arduino the ruby way Austin VanceMonday, November 5, 12
  • 2. Monday, November 5, 12
  • 3. /austinbv @austinbvMonday, November 5, 12
  • 4. arduino.. what now?Monday, November 5, 12
  • 5. arduino.. what now?Monday, November 5, 12
  • 6. arduino.. what now?Monday, November 5, 12
  • 7. arduino.. what now?Monday, November 5, 12
  • 8. arduino.. what now?Monday, November 5, 12
  • 9. arduino.. what now?Monday, November 5, 12
  • 10. arduino.. what now?Monday, November 5, 12
  • 11. arduino.. what now?Monday, November 5, 12
  • 12. arduino.. what now?Monday, November 5, 12
  • 13. arduino.. what now?Monday, November 5, 12
  • 14. what can you do with it?Monday, November 5, 12
  • 15. c a n’t what can you do with it?Monday, November 5, 12
  • 16. c a n’t What can you do with it?Monday, November 5, 12
  • 17. c a n’t What can you do with it?Monday, November 5, 12
  • 18. c a n’t What can you do with it?Monday, November 5, 12
  • 19. c a n’t What can you do with it?Monday, November 5, 12
  • 20. c a n’t What can you do with it?Monday, November 5, 12
  • 21. the ideMonday, November 5, 12
  • 22. the ideMonday, November 5, 12
  • 23. the ideMonday, November 5, 12
  • 24. rn co de Bu to t he ardu i noMonday, November 5, 12
  • 25. • standalone • isolated • smallMonday, November 5, 12
  • 26. RAD Ruby Arduino Development developed by Greg BorensteinMonday, November 5, 12
  • 27. Ruby class Blinky < ArduinoSketch output_pin 13, :as => :led def loop blink led, 100 end endMonday, November 5, 12
  • 28. Ruby compiles to C class Blinky < ArduinoSketch #include <WProgram.h> #include <SoftwareSerial.h> void loop(); output_pin 13, :as => :led void setup(); int main(); int led(); void loop(); def loop int _led = 13; int led() { blink led, 100 return _led; } end void setup() { pinMode(13, OUTPUT); end } void blink(int pin, int ms) { digitalWrite( pin, HIGH ); delay( ms ); digitalWrite( pin, LOW ); delay( ms ); } int main() { init(); setup(); for( ;; ) { loop(); } return 0; } void loop() { blink(led(), 100); }Monday, November 5, 12
  • 29. debugging outdatedMonday, November 5, 12
  • 30. alk w i th T t he A rd ui noMonday, November 5, 12
  • 31. • standalone • isolated • smallMonday, November 5, 12
  • 32. • standalone • isolated • smallMonday, November 5, 12
  • 33. • standalone • isolated • smallMonday, November 5, 12
  • 34. • standalone • isolated • smallMonday, November 5, 12
  • 35. • standalone • smallMonday, November 5, 12
  • 36. ✓standalone • smallMonday, November 5, 12
  • 37. ✓standalone ✓smallMonday, November 5, 12
  • 38. isolation is not importMonday, November 5, 12
  • 39. Monday, November 5, 12
  • 40. asyncMonday, November 5, 12
  • 41. ecto/duino “ The Arduino listens for low-level signals over a serial port, while we ” abstract all of the logic on the Node side.Monday, November 5, 12
  • 42. lo gic omp lex s c prob lem a ndMonday, November 5, 12
  • 43. lo gic omp lex s c prob lem a nd small C++ libraryMonday, November 5, 12
  • 44. message passingMonday, November 5, 12
  • 45. Monday, November 5, 12 ?
  • 46. introducing! dinoMonday, November 5, 12
  • 47. Goals • fully tested • easy to extend • great documentation • zero startup time • funMonday, November 5, 12
  • 48. beginning development and use what’s there thank you duino && node.jsMonday, November 5, 12
  • 49. Asynchronous in a synchronous worldMonday, November 5, 12
  • 50. Event MachineMonday, November 5, 12
  • 51. EM.run do board = RubyDuino::Board.new board.callback do board.send_message 0013001 do EM::add_periodic_timer 0.5 do board.send_message “0013#{blink}” end end end endMonday, November 5, 12
  • 52. Monday, November 5, 12
  • 53. roll our own • developer control • specific to the gem • zero dependenciesMonday, November 5, 12
  • 54. How did it turn out?Monday, November 5, 12
  • 55. class BoardMonday, November 5, 12
  • 56. ==Monday, November 5, 12
  • 57. Monday, November 5, 12 ♥
  • 58. class TxRxMonday, November 5, 12
  • 59. Monday, November 5, 12
  • 60. finds the arduinoMonday, November 5, 12
  • 61. injected into the boardMonday, November 5, 12
  • 62. oh the possibilitiesMonday, November 5, 12
  • 63. don’t panicMonday, November 5, 12
  • 64. module ComponentsMonday, November 5, 12
  • 65. class < BaseComponentMonday, November 5, 12
  • 66. class LedMonday, November 5, 12
  • 67. def initialize(options={}) super(options) set_pin_mode(:out) digital_write(Board::LOW) end def on digital_write(Board::HIGH) end def off digital_write(Board::LOW) endMonday, November 5, 12
  • 68. board = Board.new(Dino::TxRx.new) led = Led.new(pin: 2, board: board) led.on sleep 2 led.offMonday, November 5, 12
  • 69. class ButtonMonday, November 5, 12
  • 70. def initialize(options={}) self.board.add_digital_hardware(self) self.board.start_read end #... def update(data) case data when UP button_up when DOWN button_down end endMonday, November 5, 12
  • 71. Monday, November 5, 12
  • 72. down = proc { led.on } up = proc { led.off } button.down(down) button.up(up)Monday, November 5, 12
  • 73. class SensorMonday, November 5, 12
  • 74. def initialize(options={}) @data_callbacks = [] @board.add_analog_hardware(self) @board.start_read end def update(data) @data_callbacks.each do |callback| callback.call(data) end endMonday, November 5, 12
  • 75. on_data = proc { |data| puts data } sensor .when_data_received(on_data)Monday, November 5, 12
  • 76. class StepperMonday, November 5, 12
  • 77. def step_cc digital_write(Board::HIGH, pins[:dir]) digital_write(Board::HIGH, pins[:step]) digital_write(Board::LOW, pins[:step]) end def step_cw digital_write(Board::LOW, pins[:dir]) digital_write(Board::HIGH, pins[:step]) digital_write(Board::LOW, pins[:step]) endMonday, November 5, 12
  • 78. 1600.times do stepper.step_cc sleep 0.001 end 1600.times do stepper.step_cw sleep 0.001 endMonday, November 5, 12
  • 79. and many moreMonday, November 5, 12
  • 80. and many moreMonday, November 5, 12
  • 81. and many moreMonday, November 5, 12
  • 82. and many moreMonday, November 5, 12
  • 83. and many moreMonday, November 5, 12
  • 84. Lets see it in actionMonday, November 5, 12
  • 85. use it with any ruby script reporter = proc { if system(./build) green.on && red.off else green.off && red.on end } button.down(reporter)Monday, November 5, 12
  • 86. Monday, November 5, 12
  • 87. initializerMonday, November 5, 12
  • 88. sinatra board = Board.new(Dino::TxRx.new) cannon = Led.new(pin: 2, board: board) put ‘/launch‘ do cannon.on endMonday, November 5, 12
  • 89. Thank You! /austinbv/dino @austinbvMonday, November 5, 12