SlideShare a Scribd company logo
1 of 53
Hi!
Bodo Tasche
  @bitboxer
Endless fun with Arduino and
        Eventmachine
!              !
!
        Eventmachine
                       !
    !
?
?
        Arduino


    ?                 ?!
Source: Wikipedia
Two Parts
1. Hardware
Arduino Uno
Microcontroller               ATmega328

Operating Voltage                5V

Input Voltage (recommended)     7-12V

Input Voltage (limits)          6-20V

Digital I/O Pins                 14

Analog Input Pins                 6

DC Current per I/O Pin          40 mA

DC Current for 3.3V Pin         50 mA

Flash Memory                    32 KB

SRAM                            2 KB

EEPROM                          1 KB

Clock Speed                    16 MHz
2. So ware
http://arduino.cc
Christopher Pike, is
     this you?
const int PIN_LED = 13;

void setup() {
  pinMode(PIN_LED, OUTPUT);
}

void loop() {
  digitalWrite(PIN_LED, HIGH);
  delay(500);
  digitalWrite(PIN_LED, LOW);
  delay(500);
}
Have you brought any fruits or
   vegetables to the mars?

         Two weeks.
const int BAUD_RATE = 9600;

void setup() {
  Serial.begin(BAUD_RATE);
}

void loop() {
  Serial.println(“Hello, world!”);
  delay(1000);
}
Well, well, Private Joker, I don't
believe I heard you correctly!
http://arduino.cc/en/Tutorial/SwitchCase2
void setup() {
  Serial.begin(9600);
  for (int thisPin = 2; thisPin < 7; thisPin++) {
     pinMode(thisPin, OUTPUT);
  }
}
void loop() {
  if (Serial.available() > 0) {
    int inByte = Serial.read();
    switch (inByte) {
    case 'a': digitalWrite(2, HIGH);
              break;
    case 'b': digitalWrite(3, HIGH);
              break;
    case 'c': digitalWrite(4, HIGH);
              break;
    case 'd': digitalWrite(5, HIGH);
              break;
    case 'e': digitalWrite(6, HIGH);
              break;
    default:
      for (int thisPin = 2; thisPin < 7; thisPin++) {
        digitalWrite(thisPin, LOW);
      }
    }
  }
}
Eventmachine
     +
  Arduino
It‘s all about the volume!
Source: Wikipedia
const int POT_PIN = 2;

int val;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int newVal = map(analogRead(POT_PIN), 0, 1023, 7, 0);

    if (val != newVal) {
      val = newVal;
      Serial.println(val);
    }

}
Source: Wikipedia
require 'serialport'

sp = SerialPort.new('/dev/tty.your-usb-device', 9600, 8, 1, 0)

loop do
  line = sp.gets
  if line
    puts "New volume : #{line}"
    `osascript -e "set volume #{line}"`
  end
end

sp.close
Talk to the hand
require 'rubygems'
require 'serialport'
require 'eventmachine'

$sp = SerialPort.new('/dev/tty.your-usb-device', 9600, 8, 1, 0)

class DataBuffer < EM::Protocols::LineAndTextProtocol

  def initialize
    puts "hello stranger..."
  end

  def receive_data(data)
    EventMachine::defer do
      $sp.puts data.strip
      send_data($sp.gets)
    end
  end

end

EventMachine::run do
  EventMachine::start_server "127.0.0.1", 8081, DataBuffer
end

sp.close
EventMachine::defer
Don’t write a deferred operation
 that will block forever [...] We
might put in a timer to detect this
$eventmachine_library = :pure_ruby # need to force pure ruby
require 'eventmachine'
gem_original_require 'serialport'
require 'smsrelay/gsmpdu'

module EventMachine
  class EvmaSerialPort < StreamObject
    def self.open(dev, baud, databits, stopbits, parity)                        class << self
      io = SerialPort.new(dev, baud, databits, stopbits, parity)                  def connect_serial(dev, baud, databits, stopbits, parity)
      return(EvmaSerialPort.new(io))                                                EvmaSerialPort.open(dev, baud, databits, stopbits, parity).uuid
    end                                                                           end
                                                                                end
    def initialize(io)
      super                                                                     def EventMachine::open_serial(dev, baud, databits, stopbits, parity,
    end                                                                                                       handler=nil)
                                                                                  klass = if (handler and handler.is_a?(Class))
    ##                                                                                  handler
    # Monkeypatched version of EventMachine::StreamObject#eventable_read so           else
    # that EOFErrors from the SerialPort object (which the ruby-serialport              Class.new( Connection ) {handler and include handler}
    # library uses to signal the fact that there is no more data available            end
    # for reading) do not cause the connection to unbind.                         s = connect_serial(dev, baud, databits, stopbits, parity)
    def eventable_read                                                            c = klass.new s
       @last_activity = Reactor.instance.current_loop_time                        @conns[s] = c
       begin                                                                      block_given? and yield c
         if io.respond_to?(:read_nonblock)                                        c
           10.times {                                                           end
             data = io.read_nonblock(4096)
              EventMachine::event_callback uuid, ConnectionData, data           class Connection
           }                                                                      # This seems to be necessary with EventMachine 0.12.x
         else                                                                     def associate_callback_target(sig)
           data = io.sysread(4096)                                                  return(nil)
           EventMachine::event_callback uuid, ConnectionData, data                end
         end                                                                    end
       rescue Errno::EAGAIN, Errno::EWOULDBLOCK, EOFError                     end
         # no-op
       rescue Errno::ECONNRESET, Errno::ECONNREFUSED
         @close_scheduled = true
         EventMachine::event_callback uuid, ConnectionUnbound, nil
       end
    end
  end




          https://github.com/eventmachine/eventmachine/wiki/Code-Snippets
If you build it...
Last.fm




http://blog.last.fm/2008/08/01/quality-control
github




http://urbanhonking.com/ideasfordozens/2010/05/19/the_github_stoplight/
by-nc-nd by seanb.murphy http://www.flickr.com/photos/greenstorm/2425378283
Weather station
Infrared Sender/Receiver
Improve your
„green thumb“
CAN-bus

Connect your Arduino with your car
Gong-o-bot
Gong-o-bot
fritzing.org/projects/
fritzing.org/shop/starter-kit/
Find a hackerspace!
delicious.com/bitboxer/arduino
Don‘t be evil




                Source: Wikipedia
Be good!




           Source: Wikipedia
ank you!

More Related Content

What's hot

C++totural file
C++totural fileC++totural file
C++totural file
halaisumit
 
Javascript Uncommon Programming
Javascript Uncommon ProgrammingJavascript Uncommon Programming
Javascript Uncommon Programming
jeffz
 
OO JS for AS3 Devs
OO JS for AS3 DevsOO JS for AS3 Devs
OO JS for AS3 Devs
Jason Hanson
 
Jscex: Write Sexy JavaScript
Jscex: Write Sexy JavaScriptJscex: Write Sexy JavaScript
Jscex: Write Sexy JavaScript
jeffz
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMP
Miller Lee
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)
jeffz
 

What's hot (20)

C++totural file
C++totural fileC++totural file
C++totural file
 
About Those Python Async Concurrent Frameworks - Fantix @ OSTC 2014
About Those Python Async Concurrent Frameworks - Fantix @ OSTC 2014About Those Python Async Concurrent Frameworks - Fantix @ OSTC 2014
About Those Python Async Concurrent Frameworks - Fantix @ OSTC 2014
 
ZeroNights: Automating iOS blackbox security scanning
ZeroNights: Automating iOS blackbox security scanningZeroNights: Automating iOS blackbox security scanning
ZeroNights: Automating iOS blackbox security scanning
 
NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016
 
Checking Oracle VM VirtualBox. Part 2
Checking Oracle VM VirtualBox. Part 2Checking Oracle VM VirtualBox. Part 2
Checking Oracle VM VirtualBox. Part 2
 
Sniffing Mach Messages
Sniffing Mach MessagesSniffing Mach Messages
Sniffing Mach Messages
 
Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.
 
Javascript Uncommon Programming
Javascript Uncommon ProgrammingJavascript Uncommon Programming
Javascript Uncommon Programming
 
Spring RTS Engine Checkup
Spring RTS Engine CheckupSpring RTS Engine Checkup
Spring RTS Engine Checkup
 
OO JS for AS3 Devs
OO JS for AS3 DevsOO JS for AS3 Devs
OO JS for AS3 Devs
 
SFO15-500: VIXL
SFO15-500: VIXLSFO15-500: VIXL
SFO15-500: VIXL
 
Jscex: Write Sexy JavaScript
Jscex: Write Sexy JavaScriptJscex: Write Sexy JavaScript
Jscex: Write Sexy JavaScript
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMP
 
Python Yield
Python YieldPython Yield
Python Yield
 
Алексей Кутумов, Coroutines everywhere
Алексей Кутумов, Coroutines everywhereАлексей Кутумов, Coroutines everywhere
Алексей Кутумов, Coroutines everywhere
 
响应式编程及框架
响应式编程及框架响应式编程及框架
响应式编程及框架
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)
 
Rust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command LineRust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command Line
 
Think Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJS
 
F#语言对异步程序设计的支持
F#语言对异步程序设计的支持F#语言对异步程序设计的支持
F#语言对异步程序设计的支持
 

Similar to Endless fun with Arduino and Eventmachine

Gevent what's the point
Gevent what's the pointGevent what's the point
Gevent what's the point
seanmcq
 
Twisted logic
Twisted logicTwisted logic
Twisted logic
ashfall
 
Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!
Michael Barker
 

Similar to Endless fun with Arduino and Eventmachine (20)

R-House (LSRC)
R-House (LSRC)R-House (LSRC)
R-House (LSRC)
 
Arduino for Beginners
Arduino for BeginnersArduino for Beginners
Arduino for Beginners
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
Report for weather pi
Report for weather piReport for weather pi
Report for weather pi
 
How to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking NeedsHow to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking Needs
 
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destructionDEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
node.js - Eventful JavaScript on the Server
node.js - Eventful JavaScript on the Servernode.js - Eventful JavaScript on the Server
node.js - Eventful JavaScript on the Server
 
Scala to assembly
Scala to assemblyScala to assembly
Scala to assembly
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Gevent what's the point
Gevent what's the pointGevent what's the point
Gevent what's the point
 
C++aptitude questions and answers
C++aptitude questions and answersC++aptitude questions and answers
C++aptitude questions and answers
 
Twisted logic
Twisted logicTwisted logic
Twisted logic
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael Barker
 
Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!
 
掀起 Swift 的面紗
掀起 Swift 的面紗掀起 Swift 的面紗
掀起 Swift 的面紗
 
Checking Oracle VM VirtualBox. Part 1
Checking Oracle VM VirtualBox. Part 1Checking Oracle VM VirtualBox. Part 1
Checking Oracle VM VirtualBox. Part 1
 
Giorgio zoppi cpp11concurrency
Giorgio zoppi cpp11concurrencyGiorgio zoppi cpp11concurrency
Giorgio zoppi cpp11concurrency
 
Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)
 
Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Endless fun with Arduino and Eventmachine

  • 1. Hi!
  • 2. Bodo Tasche @bitboxer
  • 3.
  • 4. Endless fun with Arduino and Eventmachine
  • 5. ! ! ! Eventmachine ! !
  • 6. ? ? Arduino ? ?!
  • 10.
  • 12. Microcontroller ATmega328 Operating Voltage 5V Input Voltage (recommended) 7-12V Input Voltage (limits) 6-20V Digital I/O Pins 14 Analog Input Pins 6 DC Current per I/O Pin 40 mA DC Current for 3.3V Pin 50 mA Flash Memory 32 KB SRAM 2 KB EEPROM 1 KB Clock Speed 16 MHz
  • 14.
  • 16. Christopher Pike, is this you?
  • 17.
  • 18. const int PIN_LED = 13; void setup() { pinMode(PIN_LED, OUTPUT); } void loop() { digitalWrite(PIN_LED, HIGH); delay(500); digitalWrite(PIN_LED, LOW); delay(500); }
  • 19. Have you brought any fruits or vegetables to the mars? Two weeks.
  • 20. const int BAUD_RATE = 9600; void setup() { Serial.begin(BAUD_RATE); } void loop() { Serial.println(“Hello, world!”); delay(1000); }
  • 21. Well, well, Private Joker, I don't believe I heard you correctly!
  • 23. void setup() { Serial.begin(9600); for (int thisPin = 2; thisPin < 7; thisPin++) { pinMode(thisPin, OUTPUT); } }
  • 24. void loop() { if (Serial.available() > 0) { int inByte = Serial.read(); switch (inByte) { case 'a': digitalWrite(2, HIGH); break; case 'b': digitalWrite(3, HIGH); break; case 'c': digitalWrite(4, HIGH); break; case 'd': digitalWrite(5, HIGH); break; case 'e': digitalWrite(6, HIGH); break; default: for (int thisPin = 2; thisPin < 7; thisPin++) { digitalWrite(thisPin, LOW); } } } }
  • 25. Eventmachine + Arduino
  • 26. It‘s all about the volume!
  • 28. const int POT_PIN = 2; int val; void setup() { Serial.begin(9600); } void loop() { int newVal = map(analogRead(POT_PIN), 0, 1023, 7, 0); if (val != newVal) { val = newVal; Serial.println(val); } }
  • 30. require 'serialport' sp = SerialPort.new('/dev/tty.your-usb-device', 9600, 8, 1, 0) loop do line = sp.gets if line puts "New volume : #{line}" `osascript -e "set volume #{line}"` end end sp.close
  • 31. Talk to the hand
  • 32. require 'rubygems' require 'serialport' require 'eventmachine' $sp = SerialPort.new('/dev/tty.your-usb-device', 9600, 8, 1, 0) class DataBuffer < EM::Protocols::LineAndTextProtocol def initialize puts "hello stranger..." end def receive_data(data) EventMachine::defer do $sp.puts data.strip send_data($sp.gets) end end end EventMachine::run do EventMachine::start_server "127.0.0.1", 8081, DataBuffer end sp.close
  • 34. Don’t write a deferred operation that will block forever [...] We might put in a timer to detect this
  • 35. $eventmachine_library = :pure_ruby # need to force pure ruby require 'eventmachine' gem_original_require 'serialport' require 'smsrelay/gsmpdu' module EventMachine class EvmaSerialPort < StreamObject def self.open(dev, baud, databits, stopbits, parity) class << self io = SerialPort.new(dev, baud, databits, stopbits, parity) def connect_serial(dev, baud, databits, stopbits, parity) return(EvmaSerialPort.new(io)) EvmaSerialPort.open(dev, baud, databits, stopbits, parity).uuid end end end def initialize(io) super def EventMachine::open_serial(dev, baud, databits, stopbits, parity, end handler=nil) klass = if (handler and handler.is_a?(Class)) ## handler # Monkeypatched version of EventMachine::StreamObject#eventable_read so else # that EOFErrors from the SerialPort object (which the ruby-serialport Class.new( Connection ) {handler and include handler} # library uses to signal the fact that there is no more data available end # for reading) do not cause the connection to unbind. s = connect_serial(dev, baud, databits, stopbits, parity) def eventable_read c = klass.new s @last_activity = Reactor.instance.current_loop_time @conns[s] = c begin block_given? and yield c if io.respond_to?(:read_nonblock) c 10.times { end data = io.read_nonblock(4096) EventMachine::event_callback uuid, ConnectionData, data class Connection } # This seems to be necessary with EventMachine 0.12.x else def associate_callback_target(sig) data = io.sysread(4096) return(nil) EventMachine::event_callback uuid, ConnectionData, data end end end rescue Errno::EAGAIN, Errno::EWOULDBLOCK, EOFError end # no-op rescue Errno::ECONNRESET, Errno::ECONNREFUSED @close_scheduled = true EventMachine::event_callback uuid, ConnectionUnbound, nil end end end https://github.com/eventmachine/eventmachine/wiki/Code-Snippets
  • 36. If you build it...
  • 39. by-nc-nd by seanb.murphy http://www.flickr.com/photos/greenstorm/2425378283
  • 46.
  • 51. Don‘t be evil Source: Wikipedia
  • 52. Be good! Source: Wikipedia

Editor's Notes

  1. \n
  2. I am Bodo Tasche and I am working...\n
  3. \n
  4. In my spare time i have endless...\n
  5. That should be known to everyone here, right? &amp;#x201E;event-processing library for Ruby&amp;#x201C;\n
  6. That&amp;#x2018;s where the interesting stuff begins :)\n
  7. - open-source electronics prototyping platform\n-Project began 2005 in Italy to create a device for controlling student-built interaction design projects\n- Fork of &amp;#x201E; Wiring&amp;#x201C; by Hernando Barragan\n
  8. \n
  9. \n
  10. Different hardware designs, all under creative commons share alike\n
  11. I am using the arduino uno board, it&amp;#x2018;s the most common board\nInput/output Pins, USB, Reset Button\n
  12. this is the spec...that&amp;#x2018;s a &amp;#x201E;32 kb is enough for everyone&amp;#x201C; :)\n
  13. \n
  14. Open Source Editor, the language arduino is using is called processing, \nui gpl / libraries under lgpl .... rite ruby -&gt; processing\n
  15. \n
  16. Okay, now lets dive into a few examples. The hello world in the \nhardware world usually is a blinking led. That always reminds \nme on that guy in the black wheel chair thing from star trek...beep\n
  17. \n
  18. setup - init the environment of the arduino - input/output pins\nloop - the event loop\nwrite this into the editor, compile it and upload it to the arduino that is attached by usb\n
  19. lets try to communicate\n
  20. This prints hello world to the serial port every second. the arduino editor can show this in the serial monitor\n
  21. \n
  22. \n
  23. \n
  24. \n
  25. why not build everything inside of the arduino?\nmemory constraints,lazy,faster,cheaper\n
  26. \n
  27. \n
  28. \n
  29. \n
  30. Buffer the data, store it somewhere...\n
  31. You could even use the eventmachine as a proxy between a webbrowser and the arduino\n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. This shows the response time of the webservers pointer\n
  38. Contiues integration, first attempt with pc, than transformed to use an ethernet shield\ngithub repo for the code :)\n
  39. or go more extreme: signal horn :)\n
  40. you could build a simple weather station with this\narduino as data collection utility for temperature, pressure, moisture...\ncombine it with the data from the web and calculate your own weather\n
  41. \n
  42. put moisture sensors into the soil of your plants and when the\nmoisture drops a certain limit, let it send you a mail or even better:\npump water into the pot\n
  43. Petroel Heads? Read the turbocharger pressure and other things\n
  44. \n
  45. \n
  46. Fritzing is a software to document the designs you are creating \nyou can find tons of projects, schematics and sources on fritzing.org.\nyou can use that as inspiration and mix those ideas and create something new\n\n
  47. \n
  48. 55 Euro, everything you need to start developing....dingfabrik, bausteln\n
  49. \n
  50. i have tagged a few more things in my delicious account\n
  51. \n
  52. \n
  53. \n