arduino development with ruby · `ocascript -e "set volume #{line}"` end end sp.close...
TRANSCRIPT
![Page 1: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/1.jpg)
Arduino development with Ruby
Julius Markūnas
![Page 2: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/2.jpg)
What is Arduino
● Hardware
● Software
● Fun
![Page 3: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/3.jpg)
Arduino Hardware
● 8-16 Mhz processor
● 14 digital I/O pins
● 6 analog inputs
● 6 PWM outputs
● 32k flash
● 2k RAM
● Shields
![Page 4: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/4.jpg)
Arduino Shields
● Ethernet Shield
● Wi-Fi Shield
● GSM Shield
● Motor Shield
● Digit Shield
● NFC Shield
● And many more...
![Page 5: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/5.jpg)
Arduino Software
● Arduino IDE
● C like language
![Page 6: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/6.jpg)
Arduino Hello Worldint ledPin = 13; // LED connected to digital pin 13
void setup(){ pinMode(ledPin, OUTPUT); // sets the digital pin as output}
void loop(){ digitalWrite(ledPin, HIGH); // sets the LED on delay(1000); // waits for a second digitalWrite(ledPin, LOW); // sets the LED off delay(1000); // waits for a second}
![Page 7: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/7.jpg)
Arduino and Ruby
1. RAD
2. SerialPort
3. Firmata
4. Dino
![Page 8: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/8.jpg)
RAD
● Compiles to C
● Outdated
● Unmaintained
● Ruby 1.8.7
● Does not play well with Linux
![Page 9: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/9.jpg)
RAD
class MyProject < ArduinoSketch output_pin 13, :as => led def loop blink led, 500 endend
$ rake make:upload
![Page 10: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/10.jpg)
SerialPort
● Not designed for arduino
● Direct access
● Required USB cable connection
![Page 11: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/11.jpg)
SerialPortrequire 'serialport'
sp = SerialPort.new('/dev/tty.usb-device', 9600, 8, 1, 0)
loop do line = sp.gets if line puts "New volume: #{line}" `ocascript -e "set volume #{line}"` endend
sp.close
![Page 12: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/12.jpg)
Firmata
● Designed by arduino
● Access to all components
● Low level
● Requires USB cable connection
![Page 13: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/13.jpg)
Firmataarduino = ArduinoFirmata.connectpin_num = 11
loop do 0.upto(255) do |i| arduino.analog_write pin_num, i sleep 0.01 end
255.downto(0) do |i| arduino.analog_write pin_num, i sleep 0.01 endend
![Page 14: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/14.jpg)
Dino
● Most ruby like
● Good for prototyping
● Well maintained, documented
● Requires USB cable connection
![Page 15: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/15.jpg)
Dino
board = Dino::Board.new(Dino::TxRx.new)led = Dino::Components::Led.new(pin: 13, board: board)
[:on, :off].cycle do |switch| led.send(switch) sleep 0.5end
![Page 16: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/16.jpg)
Fun - Github stoplight
http://urbanhonking.com/ideasfordozens/2010/05/19/the_github_stoplight/
![Page 17: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/17.jpg)
Fun - Led coat
http://rgbledcoat.blogspot.com/
![Page 18: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/18.jpg)
Fun - Barduino
http://www.matthewdavidwilliams.com/2008/10/17/introducing-barduino-the-ruby-powered-bar-monkey/
![Page 19: Arduino development with Ruby · `ocascript -e "set volume #{line}"` end end sp.close Firmata Designed by arduino Access to all components Low level Requires USB cable connection](https://reader034.vdocuments.mx/reader034/viewer/2022050500/5f93389c7d27441a58007fe3/html5/thumbnails/19.jpg)
Fun - Demo
Led Cube