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
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
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
That should be known to everyone here, right? &#x201E;event-processing library for Ruby&#x201C;\n
That&#x2018;s where the interesting stuff begins :)\n
- 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 &#x201E; Wiring&#x201C; by Hernando Barragan\n
\n
\n
Different hardware designs, all under creative commons share alike\n
I am using the arduino uno board, it&#x2018;s the most common board\nInput/output Pins, USB, Reset Button\n
this is the spec...that&#x2018;s a &#x201E;32 kb is enough for everyone&#x201C; :)\n
\n
Open Source Editor, the language arduino is using is called processing, \nui gpl / libraries under lgpl .... rite ruby -> processing\n
\n
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
\n
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
lets try to communicate\n
This prints hello world to the serial port every second. the arduino editor can show this in the serial monitor\n
\n
\n
\n
\n
why not build everything inside of the arduino?\nmemory constraints,lazy,faster,cheaper\n
\n
\n
\n
\n
Buffer the data, store it somewhere...\n
You could even use the eventmachine as a proxy between a webbrowser and the arduino\n
\n
\n
\n
\n
\n
This shows the response time of the webservers pointer\n
Contiues integration, first attempt with pc, than transformed to use an ethernet shield\ngithub repo for the code :)\n
or go more extreme: signal horn :)\n
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
\n
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
Petroel Heads? Read the turbocharger pressure and other things\n
\n
\n
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
\n
55 Euro, everything you need to start developing....dingfabrik, bausteln\n
\n
i have tagged a few more things in my delicious account\n