SlideShare ist ein Scribd-Unternehmen logo
1 von 65
Arduino and Ruby
with a (tiny bit of) shoes
         Martin Evans
Summary
• Arduino
• RAD (Ruby Arduino Development)
• Examples
• Projects
Arduino
• http://arduino.cc
• Examples
• Tutorials
• Downloads
• Forum
Hardware




Photo by adafruit - http://flic.kr/p/7LyorG
Photo by pt - http://flic.kr/p/7Luj6T
Duemilanove (2009)
•   ATMega328p

•   60,000 sold 2009

•   6 Analog pins

•   14 Digital pins

•   PWM: 3, 5, 6, 9, 10,
    and 11.


•   16 Mhz

•
                            Photo by vouki - http://flic.kr/p/5V6KkG
    Auto external Voltage
Diecimila (10 thousand)
•   ATMega168

•   16 Mhz

•   14 digital I/O 6 pwm

•   6 Analog inputs

•   7 - 12 v


                           Photo by Remko van Dokkum - http://flic.kr/p/54JcXJ
Mega
•   ATMega1280

•   Analog 16 pins

•   54 Digital

•   14 PWM



                     Photo by Spikenzie - http://flic.kr/p/6ahHFu
Nano   Lilypad




Mini

       Photo by dodeckahedron - http://
               flic.kr/p/3fM8aA
Photo by Osamu Iwasaki - http://flic.kr/p/79ymo7
Shields
•   Ethernet

•   Wifi

•   Motor

•   I/O

•   Xbee

•   Prototype

                   Photo by knolleary - http://flic.kr/p/4YaR9k
Motor controller




 Photo by Alcoholwang - http://flic.kr/p/69yE7E
I/O Board




Photo by Alcoholwang - http://flic.kr/p/69yEch
Software
•   Processing

•   Basic IDE

•   Cross platform

•   Latest Version is 18
RAD
• Ruby Arduino Development
• Greg Borenstein 2007
• git://github.com/atduskgreg/rad.git
• http://github.com/madrona/rad
Installation
$ sudo gem install madrona-rad

$ rad example
Hardware.yml
############################################################
##
# Today's MCU Choices (replace the mcu with your arduino board)
# atmega8 => Arduino NG or older w/ ATmega8
# atmega168 => Arduino NG or older w/ ATmega168
# mini => Arduino Mini
# bt => Arduino BT
# diecimila => Arduino Diecimila or Duemilanove w/ ATmega168
# nano => Arduino Nano
# lilypad => LilyPad Arduino
# pro => Arduino Pro or Pro Mini (8 MHz)
# atmega328 => Arduino Duemilanove w/ ATmega328
# mega => Arduino Mega

---
serial_port: /dev/tty.usbserial*
physical_reset: false
mcu: atmega168
software.yml
---
arduino_root: /Applications/arduino-0015
Compile
rake make:upload
Getting Started with
      Arduino
      by Massimo Banzi
Blink LED
// Blinking LED

#define LED 13 // LED connected to
         // Digital pin 13

void setup ()
 {
   pinMode(LED, OUTPUT); // sets the digital
               // pin as output
}

void loop()
{
  digitalWrite(LED, HIGH); // turns the LED on
  delay(1000);          // waits for a second
  digitalWrite(LED, LOW); // turns the LED off
  delay(1000);         // waits for a second
}
Blink LED
class BlinkLed < ArduinoSketch



   output_pin 13, :as => :led

   def loop
    blink led, 1000
   end

end
Fade LED in and out
int ledPin = 9;    // LED connected to digital pin 9

void setup() {
  // nothing happens in setup
}

void loop() {
 // fade in from min to max in increments of 5 points:
 for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
   // sets the value (range from 0 to 255):
   analogWrite(ledPin, fadeValue);
   // wait for 30 milliseconds to see the dimming effect
   delay(30);
 }

    // fade out from max to min in increments of 5 points:
    for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
      // sets the value (range from 0 to 255):
      analogWrite(ledPin, fadeValue);
      // wait for 30 milliseconds to see the dimming effect
      delay(30);
    }
}
Fade LED in and out
 class Analogled < ArduinoSketch

    output_pin 9, :as => :led
   @i = 1

   def loop
     while @i < 255 do
      analogWrite led, @i
      @i +=5
      delay 30
     end
     while @i > 0 do
      analogWrite led, @i
      @i -=5
      delay 30
     end
   end
 end
Blink LED analogue input
int sensorPin = 0; // select the input pin for the sensor
int ledPin = 13;   // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from
                        // the sensor

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);
  // turn the ledPin off:
  digitalWrite(ledPin, LOW);
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);
}
Blink LED analogue input
    class Analoginput < ArduinoSketch

       output_pin 13, :as => :led
      @val = 0

      def loop
        @val = analogRead(0)
        digitalWrite (led, 1)
        delay @val
        digitalWrite (led, 0)
        delay @val
      end
    end
Blink LED analogue input
Blink LED analogue input
Serial Read
class Serialcom1 < ArduinoSketch

    input_pin 0, :as => :sensor

    serial_begin :rate => 19200

    def loop
     serial_println analogRead sensor
     delay 1000
    end
 end
Plugins and Libraries
•   C Methods, directives,
    external variables and
    assignments and calls
    that maybe added to
    main setup method

•   Arduino libraries
Servo code
class Servo < ArduinoSketch
 output_pin 11, :as => :servo, :device => :servo
 def loop
   servo_refresh
   servo.position 90
 end
end
class Servo < ArduinoSketch
 output_pin 11, :as => :my_servo, :device => :servo
 def loop
   servo_refresh
   my_servo.position 180
   servo_delay 1000
   my_servo.position 0
   servo_delay 1000
 end

 def servo_delay(t)
  t.times do
    delay 1
    servo_refresh
  end
 end
end
Example Projects
    Ruby on Bells

      Barduino

     Flying Robot
Ruby on bells
   JD Barnhart
Ruby on Bells




   JD Barnhart
Ruby on Bells




   JD Barnhart
Barduino
         Matthew Williams

http://github.com/mwilliams/barduino
Barduino




Photo by aeden - http://flic.kr/p/5uy7DX
Barduino
Barduino
Flying Robot
              Damen and Ron Evans

http://wiki.github.com/deadprogrammer/flying_robot/

        http://github.com/deadprogrammer/
              flying_robot_blimpduino

   http://deadprogrammersociety.blogspot.com/
Flying Robot




Photo by Austin Ziegler - http://flic.kr/p/6DXQqV
Flying Robot
Flying Robot
Shoes

• Snow Leopard Fail
• Toholio serial gem
Flying Robot code
• Background
• Draw images
• Serial update
• XBee
Shoes.setup do
 gem 'toholio-serialport'
end

require "serialport"
require 'lib/flying_robot_proxy'

FLYING_ROBOT = FlyingRobotProxy.new
def draw_background
  @centerx, @centery = 126, 140

  fill white
  stroke black
  strokewidth 4
  oval @centerx - 102, @centery - 102, 204, 204

  fill black
  nostroke
  oval @centerx - 5, @centery - 5, 10, 10

  stroke black
  strokewidth 1
  line(@centerx, @centery - 102, @centerx, @centery - 95)
  line(@centerx - 102, @centery, @centerx - 95, @centery)
  line(@centerx + 95, @centery, @centerx + 102, @centery)
  line(@centerx, @centery + 95, @centerx, @centery + 102)
  @north = para "N", :top => @centery - 130, :left => @centerx - 10
  @south = para "S", :top => @centery + 104, :left => @centerx - 10
  @west = para "W", :top => @centery - 12, :left => @centerx - 126
  @east = para "E", :top => @centery - 12, :left => @centerx + 104
 end
def draw_compass_hand
  @centerx, @centery = 126, 140
  @current_reading = @compass.to_f #[17, @compass.length].to_f
  return if @current_reading == 0.0
  # the compass is oriented in reverse on the blimpduino, so switch it
  @current_reading = (@current_reading + 180).modulo(360)
  _x = 90 * Math.sin( @current_reading * Math::PI / 180 )
  _y = 90 * Math.cos( @current_reading * Math::PI / 180 )
  stroke black
  strokewidth 6
  line(@centerx, @centery, @centerx + _x, @centery - _y)
 end
Sharp GP2D12




Photo by hmblgrmpf - http://flic.kr/p/hJmoM
Sharp GP2D12 code
class Sharpir < ArduinoSketch
 # Analog input for sharp Infrared sensors GP2D12
  input_pin 0, :as => :ir_sensor_right
 # variables for checking for obstruction
  @range = "0, int"
  serial_begin

  def loop
    range_ir_sensor
    delay 10
  end

  def range_ir_sensor
     @range = analogRead(ir_sensor)
      if (@range> 3) then
          @range = (6787 / (@range - 3)) - 4
          serial_print "sensor: "
          serial_println @range
          delay 1000
      end
  end
end
Devantech SRF05



  Photo by Lucky Larry - http://flic.kr/p/6E5pZZ
Devantech SRF05
class Rangefinding < ArduinoSketch

 @sig_pin = 2

 serial_begin

 def loop
    serial_println(pingsrf05(@sig_pin))
 end
end
class Srf05 < ArduinoPlugin

 # Triggers a pulse and returns distance in cm.

 long pingsrf05(int ultraSoundpin) {
   unsigned long ultrasoundDuration;
   // switch pin to output
    pinMode(ultraSoundpin, OUTPUT);

     // send a low, wait 2 microseconds, send a high then wait 10us
     digitalWrite(ultraSoundpin, LOW);
     delayMicroseconds(2);
     digitalWrite(ultraSoundpin, HIGH);
     delayMicroseconds(10);
     digitalWrite(ultraSoundpin, LOW);

      // switch pin to input
     pinMode(ultraSoundpin, INPUT);

      // wait for a pulse to come in as high
      ultrasoundDuration = pulseIn(ultraSoundpin, HIGH);
     return(ultrasoundDuration/58);
 }

end
Wishield




Asynclabs
Pachube
• http://www.pachube.com
• Sign up for account
• Get api key
• http://www.pachube.com/feeds/6445
Roo-bee
• Obstacle avoidance
• Sharp IR sensors
• Arduino Duemilanove
• Devantech SR05 Ultrasound
• Servo
• Solarbotics Motors
DEMO
Suppliers
• Active robots: http://active-robots.com
• Ebay jzhaoket and yerobot
• http://asynclabs.com
• http://bitsbox.co.uk
Thanks
• Github http://github.com/lostcaggy
• Slides will be on slideshare later

Weitere ähnliche Inhalte

Was ist angesagt?

Workshop at IAMAS 2008-05-24
Workshop at IAMAS 2008-05-24Workshop at IAMAS 2008-05-24
Workshop at IAMAS 2008-05-24Shigeru Kobayashi
 
Cranking Floating Point Performance To 11 On The iPhone
Cranking Floating Point Performance To 11 On The iPhoneCranking Floating Point Performance To 11 On The iPhone
Cranking Floating Point Performance To 11 On The iPhoneNoel Llopis
 
DomCode 2015 - Abusing phones to make the internet of things
DomCode 2015 - Abusing phones to make the internet of thingsDomCode 2015 - Abusing phones to make the internet of things
DomCode 2015 - Abusing phones to make the internet of thingsJan Jongboom
 
Make ARM Shellcode Great Again
Make ARM Shellcode Great AgainMake ARM Shellcode Great Again
Make ARM Shellcode Great AgainSaumil Shah
 
Using Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate ReptiliansUsing Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate ReptiliansNilhcem
 
Eco-Friendly Hardware Hacking with Android
Eco-Friendly Hardware Hacking with AndroidEco-Friendly Hardware Hacking with Android
Eco-Friendly Hardware Hacking with AndroidCarlo Pescio
 
[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)Simen Li
 
Getting Started with Raspberry Pi - USC 2013
Getting Started with Raspberry Pi - USC 2013Getting Started with Raspberry Pi - USC 2013
Getting Started with Raspberry Pi - USC 2013Tom Paulus
 
Make ARM Shellcode Great Again - HITB2018PEK
Make ARM Shellcode Great Again - HITB2018PEKMake ARM Shellcode Great Again - HITB2018PEK
Make ARM Shellcode Great Again - HITB2018PEKSaumil Shah
 
HackLU 2018 Make ARM Shellcode Great Again
HackLU 2018 Make ARM Shellcode Great AgainHackLU 2018 Make ARM Shellcode Great Again
HackLU 2018 Make ARM Shellcode Great AgainSaumil Shah
 
The Unicorn's Travel to the Microcosm
The Unicorn's Travel to the MicrocosmThe Unicorn's Travel to the Microcosm
The Unicorn's Travel to the MicrocosmAndrey Karpov
 
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, NepalArduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepalbishal bhattarai
 
Environmental effects - a ray tracing exercise
Environmental effects - a ray tracing exerciseEnvironmental effects - a ray tracing exercise
Environmental effects - a ray tracing exercisePierangelo Cecchetto
 
Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11John Wilker
 
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)Pixie Labs
 
Mdp plus 2.1
Mdp plus 2.1Mdp plus 2.1
Mdp plus 2.1boedax
 
ARM Polyglot Shellcode - HITB2019AMS
ARM Polyglot Shellcode - HITB2019AMSARM Polyglot Shellcode - HITB2019AMS
ARM Polyglot Shellcode - HITB2019AMSSaumil Shah
 
Schrödinger's ARM Assembly
Schrödinger's ARM AssemblySchrödinger's ARM Assembly
Schrödinger's ARM AssemblySaumil Shah
 

Was ist angesagt? (20)

Workshop at IAMAS 2008-05-24
Workshop at IAMAS 2008-05-24Workshop at IAMAS 2008-05-24
Workshop at IAMAS 2008-05-24
 
Cranking Floating Point Performance To 11 On The iPhone
Cranking Floating Point Performance To 11 On The iPhoneCranking Floating Point Performance To 11 On The iPhone
Cranking Floating Point Performance To 11 On The iPhone
 
DomCode 2015 - Abusing phones to make the internet of things
DomCode 2015 - Abusing phones to make the internet of thingsDomCode 2015 - Abusing phones to make the internet of things
DomCode 2015 - Abusing phones to make the internet of things
 
Make ARM Shellcode Great Again
Make ARM Shellcode Great AgainMake ARM Shellcode Great Again
Make ARM Shellcode Great Again
 
Using Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate ReptiliansUsing Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate Reptilians
 
Eco-Friendly Hardware Hacking with Android
Eco-Friendly Hardware Hacking with AndroidEco-Friendly Hardware Hacking with Android
Eco-Friendly Hardware Hacking with Android
 
[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)
 
Getting Started with Raspberry Pi - USC 2013
Getting Started with Raspberry Pi - USC 2013Getting Started with Raspberry Pi - USC 2013
Getting Started with Raspberry Pi - USC 2013
 
Make ARM Shellcode Great Again - HITB2018PEK
Make ARM Shellcode Great Again - HITB2018PEKMake ARM Shellcode Great Again - HITB2018PEK
Make ARM Shellcode Great Again - HITB2018PEK
 
HackLU 2018 Make ARM Shellcode Great Again
HackLU 2018 Make ARM Shellcode Great AgainHackLU 2018 Make ARM Shellcode Great Again
HackLU 2018 Make ARM Shellcode Great Again
 
The Unicorn's Travel to the Microcosm
The Unicorn's Travel to the MicrocosmThe Unicorn's Travel to the Microcosm
The Unicorn's Travel to the Microcosm
 
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, NepalArduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
 
Environmental effects - a ray tracing exercise
Environmental effects - a ray tracing exerciseEnvironmental effects - a ray tracing exercise
Environmental effects - a ray tracing exercise
 
Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11
 
Arduino reference
Arduino referenceArduino reference
Arduino reference
 
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
 
Mdp plus 2.1
Mdp plus 2.1Mdp plus 2.1
Mdp plus 2.1
 
ARM Polyglot Shellcode - HITB2019AMS
ARM Polyglot Shellcode - HITB2019AMSARM Polyglot Shellcode - HITB2019AMS
ARM Polyglot Shellcode - HITB2019AMS
 
Schrödinger's ARM Assembly
Schrödinger's ARM AssemblySchrödinger's ARM Assembly
Schrödinger's ARM Assembly
 
Arduino
ArduinoArduino
Arduino
 

Andere mochten auch

Andere mochten auch (10)

présentation finale
présentation finaleprésentation finale
présentation finale
 
Mechi R0807
Mechi R0807Mechi R0807
Mechi R0807
 
Marwen2
Marwen2Marwen2
Marwen2
 
Histoire de la robotique
Histoire de la robotiqueHistoire de la robotique
Histoire de la robotique
 
Presentation arduino
Presentation arduinoPresentation arduino
Presentation arduino
 
ROBOT à base d'Android - Présentation PFE
ROBOT à base d'Android - Présentation PFEROBOT à base d'Android - Présentation PFE
ROBOT à base d'Android - Présentation PFE
 
Logiciels avec algorigrammes
Logiciels avec algorigrammesLogiciels avec algorigrammes
Logiciels avec algorigrammes
 
Les Dictionnaires
Les DictionnairesLes Dictionnaires
Les Dictionnaires
 
2743557 dossier-ppe-robot-suiveur-de-ligne
2743557 dossier-ppe-robot-suiveur-de-ligne2743557 dossier-ppe-robot-suiveur-de-ligne
2743557 dossier-ppe-robot-suiveur-de-ligne
 
Guide d’activités THYMIO - Fréquence Écoles
Guide d’activités THYMIO - Fréquence ÉcolesGuide d’activités THYMIO - Fréquence Écoles
Guide d’activités THYMIO - Fréquence Écoles
 

Ähnlich wie Scottish Ruby Conference 2010 Arduino, Ruby RAD

Cassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshopCassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshoptomtobback
 
Arduino: Analog I/O
Arduino: Analog I/OArduino: Analog I/O
Arduino: Analog I/OJune-Hao Hou
 
Introduction to Arduino and Circuits
Introduction to Arduino and CircuitsIntroduction to Arduino and Circuits
Introduction to Arduino and CircuitsJason Griffey
 
Syed IoT - module 5
Syed  IoT - module 5Syed  IoT - module 5
Syed IoT - module 5Syed Mustafa
 
Arduino for Beginners
Arduino for BeginnersArduino for Beginners
Arduino for BeginnersSarwan Singh
 
Arduino cic3
Arduino cic3Arduino cic3
Arduino cic3Jeni Shah
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdfJayanthi Kannan MK
 
Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Tom Paulus
 
Arduino اردوينو
Arduino اردوينوArduino اردوينو
Arduino اردوينوsalih mahmod
 
Introduction to arduino Programming with
Introduction to arduino Programming withIntroduction to arduino Programming with
Introduction to arduino Programming withlikhithkumpala159
 
Arduino windows remote control
Arduino windows remote controlArduino windows remote control
Arduino windows remote controlVilayatAli5
 
Multi Sensory Communication 2/2
Multi Sensory Communication 2/2Multi Sensory Communication 2/2
Multi Sensory Communication 2/2Satoru Tokuhisa
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerMujahid Hussain
 

Ähnlich wie Scottish Ruby Conference 2010 Arduino, Ruby RAD (20)

Cassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshopCassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshop
 
Arduino: Analog I/O
Arduino: Analog I/OArduino: Analog I/O
Arduino: Analog I/O
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Introduction to Arduino and Circuits
Introduction to Arduino and CircuitsIntroduction to Arduino and Circuits
Introduction to Arduino and Circuits
 
Syed IoT - module 5
Syed  IoT - module 5Syed  IoT - module 5
Syed IoT - module 5
 
Arduino programming
Arduino programmingArduino programming
Arduino programming
 
Arduino for Beginners
Arduino for BeginnersArduino for Beginners
Arduino for Beginners
 
Arduino cic3
Arduino cic3Arduino cic3
Arduino cic3
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
 
Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013
 
Arduino اردوينو
Arduino اردوينوArduino اردوينو
Arduino اردوينو
 
Intro to-the-arduino
Intro to-the-arduinoIntro to-the-arduino
Intro to-the-arduino
 
Introduction to arduino Programming with
Introduction to arduino Programming withIntroduction to arduino Programming with
Introduction to arduino Programming with
 
Arduino windows remote control
Arduino windows remote controlArduino windows remote control
Arduino windows remote control
 
Led fade
Led  fadeLed  fade
Led fade
 
Multi Sensory Communication 2/2
Multi Sensory Communication 2/2Multi Sensory Communication 2/2
Multi Sensory Communication 2/2
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
 
Arduino Programming Basic
Arduino Programming BasicArduino Programming Basic
Arduino Programming Basic
 

Kürzlich hochgeladen

Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Kürzlich hochgeladen (20)

Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

Scottish Ruby Conference 2010 Arduino, Ruby RAD

  • 1. Arduino and Ruby with a (tiny bit of) shoes Martin Evans
  • 2. Summary • Arduino • RAD (Ruby Arduino Development) • Examples • Projects
  • 3. Arduino • http://arduino.cc • Examples • Tutorials • Downloads • Forum
  • 4. Hardware Photo by adafruit - http://flic.kr/p/7LyorG
  • 5. Photo by pt - http://flic.kr/p/7Luj6T
  • 6. Duemilanove (2009) • ATMega328p • 60,000 sold 2009 • 6 Analog pins • 14 Digital pins • PWM: 3, 5, 6, 9, 10, and 11. • 16 Mhz • Photo by vouki - http://flic.kr/p/5V6KkG Auto external Voltage
  • 7. Diecimila (10 thousand) • ATMega168 • 16 Mhz • 14 digital I/O 6 pwm • 6 Analog inputs • 7 - 12 v Photo by Remko van Dokkum - http://flic.kr/p/54JcXJ
  • 8. Mega • ATMega1280 • Analog 16 pins • 54 Digital • 14 PWM Photo by Spikenzie - http://flic.kr/p/6ahHFu
  • 9. Nano Lilypad Mini Photo by dodeckahedron - http:// flic.kr/p/3fM8aA
  • 10. Photo by Osamu Iwasaki - http://flic.kr/p/79ymo7
  • 11. Shields • Ethernet • Wifi • Motor • I/O • Xbee • Prototype Photo by knolleary - http://flic.kr/p/4YaR9k
  • 12. Motor controller Photo by Alcoholwang - http://flic.kr/p/69yE7E
  • 13. I/O Board Photo by Alcoholwang - http://flic.kr/p/69yEch
  • 14. Software • Processing • Basic IDE • Cross platform • Latest Version is 18
  • 15. RAD • Ruby Arduino Development • Greg Borenstein 2007 • git://github.com/atduskgreg/rad.git • http://github.com/madrona/rad
  • 16. Installation $ sudo gem install madrona-rad $ rad example
  • 17.
  • 18. Hardware.yml ############################################################ ## # Today's MCU Choices (replace the mcu with your arduino board) # atmega8 => Arduino NG or older w/ ATmega8 # atmega168 => Arduino NG or older w/ ATmega168 # mini => Arduino Mini # bt => Arduino BT # diecimila => Arduino Diecimila or Duemilanove w/ ATmega168 # nano => Arduino Nano # lilypad => LilyPad Arduino # pro => Arduino Pro or Pro Mini (8 MHz) # atmega328 => Arduino Duemilanove w/ ATmega328 # mega => Arduino Mega --- serial_port: /dev/tty.usbserial* physical_reset: false mcu: atmega168
  • 21. Getting Started with Arduino by Massimo Banzi
  • 22. Blink LED // Blinking LED #define LED 13 // LED connected to // Digital pin 13 void setup () { pinMode(LED, OUTPUT); // sets the digital // pin as output } void loop() { digitalWrite(LED, HIGH); // turns the LED on delay(1000); // waits for a second digitalWrite(LED, LOW); // turns the LED off delay(1000); // waits for a second }
  • 23. Blink LED class BlinkLed < ArduinoSketch output_pin 13, :as => :led def loop blink led, 1000 end end
  • 24. Fade LED in and out int ledPin = 9; // LED connected to digital pin 9 void setup() { // nothing happens in setup } void loop() { // fade in from min to max in increments of 5 points: for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { // sets the value (range from 0 to 255): analogWrite(ledPin, fadeValue); // wait for 30 milliseconds to see the dimming effect delay(30); } // fade out from max to min in increments of 5 points: for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { // sets the value (range from 0 to 255): analogWrite(ledPin, fadeValue); // wait for 30 milliseconds to see the dimming effect delay(30); } }
  • 25. Fade LED in and out class Analogled < ArduinoSketch output_pin 9, :as => :led @i = 1 def loop while @i < 255 do analogWrite led, @i @i +=5 delay 30 end while @i > 0 do analogWrite led, @i @i -=5 delay 30 end end end
  • 26. Blink LED analogue input int sensorPin = 0; // select the input pin for the sensor int ledPin = 13; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from // the sensor void setup() { // declare the ledPin as an OUTPUT: pinMode(ledPin, OUTPUT); } void loop() { // read the value from the sensor: sensorValue = analogRead(sensorPin); // turn the ledPin on digitalWrite(ledPin, HIGH); // stop the program for <sensorValue> milliseconds: delay(sensorValue); // turn the ledPin off: digitalWrite(ledPin, LOW); // stop the program for for <sensorValue> milliseconds: delay(sensorValue); }
  • 27. Blink LED analogue input class Analoginput < ArduinoSketch output_pin 13, :as => :led @val = 0 def loop @val = analogRead(0) digitalWrite (led, 1) delay @val digitalWrite (led, 0) delay @val end end
  • 30. Serial Read class Serialcom1 < ArduinoSketch input_pin 0, :as => :sensor serial_begin :rate => 19200 def loop serial_println analogRead sensor delay 1000 end end
  • 31. Plugins and Libraries • C Methods, directives, external variables and assignments and calls that maybe added to main setup method • Arduino libraries
  • 32. Servo code class Servo < ArduinoSketch output_pin 11, :as => :servo, :device => :servo def loop servo_refresh servo.position 90 end end
  • 33. class Servo < ArduinoSketch output_pin 11, :as => :my_servo, :device => :servo def loop servo_refresh my_servo.position 180 servo_delay 1000 my_servo.position 0 servo_delay 1000 end def servo_delay(t) t.times do delay 1 servo_refresh end end end
  • 34. Example Projects Ruby on Bells Barduino Flying Robot
  • 35. Ruby on bells JD Barnhart
  • 36. Ruby on Bells JD Barnhart
  • 37. Ruby on Bells JD Barnhart
  • 38. Barduino Matthew Williams http://github.com/mwilliams/barduino
  • 39. Barduino Photo by aeden - http://flic.kr/p/5uy7DX
  • 42. Flying Robot Damen and Ron Evans http://wiki.github.com/deadprogrammer/flying_robot/ http://github.com/deadprogrammer/ flying_robot_blimpduino http://deadprogrammersociety.blogspot.com/
  • 43. Flying Robot Photo by Austin Ziegler - http://flic.kr/p/6DXQqV
  • 46. Shoes • Snow Leopard Fail • Toholio serial gem
  • 47. Flying Robot code • Background • Draw images • Serial update • XBee
  • 48. Shoes.setup do gem 'toholio-serialport' end require "serialport" require 'lib/flying_robot_proxy' FLYING_ROBOT = FlyingRobotProxy.new
  • 49. def draw_background @centerx, @centery = 126, 140 fill white stroke black strokewidth 4 oval @centerx - 102, @centery - 102, 204, 204 fill black nostroke oval @centerx - 5, @centery - 5, 10, 10 stroke black strokewidth 1 line(@centerx, @centery - 102, @centerx, @centery - 95) line(@centerx - 102, @centery, @centerx - 95, @centery) line(@centerx + 95, @centery, @centerx + 102, @centery) line(@centerx, @centery + 95, @centerx, @centery + 102) @north = para "N", :top => @centery - 130, :left => @centerx - 10 @south = para "S", :top => @centery + 104, :left => @centerx - 10 @west = para "W", :top => @centery - 12, :left => @centerx - 126 @east = para "E", :top => @centery - 12, :left => @centerx + 104 end
  • 50. def draw_compass_hand @centerx, @centery = 126, 140 @current_reading = @compass.to_f #[17, @compass.length].to_f return if @current_reading == 0.0 # the compass is oriented in reverse on the blimpduino, so switch it @current_reading = (@current_reading + 180).modulo(360) _x = 90 * Math.sin( @current_reading * Math::PI / 180 ) _y = 90 * Math.cos( @current_reading * Math::PI / 180 ) stroke black strokewidth 6 line(@centerx, @centery, @centerx + _x, @centery - _y) end
  • 51. Sharp GP2D12 Photo by hmblgrmpf - http://flic.kr/p/hJmoM
  • 52. Sharp GP2D12 code class Sharpir < ArduinoSketch # Analog input for sharp Infrared sensors GP2D12 input_pin 0, :as => :ir_sensor_right # variables for checking for obstruction @range = "0, int" serial_begin def loop range_ir_sensor delay 10 end def range_ir_sensor @range = analogRead(ir_sensor) if (@range> 3) then @range = (6787 / (@range - 3)) - 4 serial_print "sensor: " serial_println @range delay 1000 end end end
  • 53. Devantech SRF05 Photo by Lucky Larry - http://flic.kr/p/6E5pZZ
  • 54. Devantech SRF05 class Rangefinding < ArduinoSketch @sig_pin = 2 serial_begin def loop serial_println(pingsrf05(@sig_pin)) end end
  • 55. class Srf05 < ArduinoPlugin # Triggers a pulse and returns distance in cm. long pingsrf05(int ultraSoundpin) { unsigned long ultrasoundDuration; // switch pin to output pinMode(ultraSoundpin, OUTPUT); // send a low, wait 2 microseconds, send a high then wait 10us digitalWrite(ultraSoundpin, LOW); delayMicroseconds(2); digitalWrite(ultraSoundpin, HIGH); delayMicroseconds(10); digitalWrite(ultraSoundpin, LOW); // switch pin to input pinMode(ultraSoundpin, INPUT); // wait for a pulse to come in as high ultrasoundDuration = pulseIn(ultraSoundpin, HIGH); return(ultrasoundDuration/58); } end
  • 57. Pachube • http://www.pachube.com • Sign up for account • Get api key • http://www.pachube.com/feeds/6445
  • 58. Roo-bee • Obstacle avoidance • Sharp IR sensors • Arduino Duemilanove • Devantech SR05 Ultrasound • Servo • Solarbotics Motors
  • 59.
  • 60.
  • 61.
  • 62.
  • 63. DEMO
  • 64. Suppliers • Active robots: http://active-robots.com • Ebay jzhaoket and yerobot • http://asynclabs.com • http://bitsbox.co.uk
  • 65. Thanks • Github http://github.com/lostcaggy • Slides will be on slideshare later

Hinweis der Redaktion

  1. Great documentation, active forum
  2. 2005 ATMega 8Open sourceBuild own
  3. Most Common and easiest to use 32 kb flash memory 7-12v LED 13 Many clones offer same or extra functionality
  4. Sold 10,000 Previous version of the current USB Arduino board 16kb flash memory
  5. The big one shield compatible 128kb flash memory 4 hardware uarts
  6. Different versionsLilypad 8Mhzsewn onto clothes stylish puple
  7. Lilypad example
  8. EthernetStackable
  9. Motor
  10. I/O BoardEasy to add servos and sensorsAdd Bluetooth as Serial port
  11. Processing also need to install usb driver suitable for your platform
  12. Main Gem outdatedMadrona fork GithubRuby 1.91 readyBrian Lyles Fork can use 18 Uses Ruby2c
  13. Basic Installaton on Mac OS X Instructions of Github for other flavours RAD creates directory stucture
  14. lots of examples in the examples directory
  15. Hardware setup
  16. Software set up
  17. Write coderake make:upload
  18. Co-founder of Arduino Excellent BookEasy start Well explained Examples
  19. Processing code
  20. Blink LED at rate dependent on sensor value
  21. Blinks LED at rate set by sensor
  22. Plugins preferred methodLibraries give access to quite a few devices
  23. servo refresh called roughly every 50ms, won&amp;#x2019;t call less than 20 to keep position library device:servo tells us to work with servo library written by Brian Riley
  24. moving between 2 points, note servo_delay
  25. flying robot then adapted to work with blimpduino
  26. Ruby conf 2008
  27. Problems shoesSnow Leopard Actively being worked on this was where I was going to show my robot linked to shoes however we can briefly look at flying robot code
  28. XBees but could use any serial interface
  29. Start up in shoes lib serial code
  30. background
  31. compass
  32. 3 look left right and centre
  33. analogue non linear, algorithm Tom Igoe&amp;#x2019;s book Making things talk
  34. Two modes control of ping 4 wires or 3 4th wire tied to ground
  35. plugin, digital pin
  36. plugin pass pin in and returns distance
  37. Wishield Wifi
  38. wishield only arrived from United States the other day so still need to write plugin. Arduino working for a few hours sending light values and temperature
  39. ModularStackable shieldsPing noise run in circlelooks for clear path
  40. No affiliation, working on adding speech and getting bluetooth working with shoes