Sha256: 228d9fa65ae3ccd61846ea69af695fe66c3b47939a15548600e93622efa9f999

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 Bytes

Contents

require 'artoo'

#Circuit's breadboard layout for the L293D here: http://www.electrojoystick.com/tutorial/?p=759
#For the L239DNE: http://bit.ly/14QdjD5,
#   L293DNE's pin 1 should go to 5V instead of to Arduino's pin 9

connection :firmata, :adaptor => :firmata, :port => '/dev/ttyACM0' # linux
#connection :firmata, :adaptor => :firmata, :port => '127.0.0.1:8023'
device :board, :driver => :device_info
device :motor, :driver => :motor, :forward_pin => 4, :backward_pin => 2

work do
  puts "Firmware name: #{board.firmware_name}"
  puts "Firmata version: #{board.version}"
  puts "Stopping motor..."
  motor.stop
  sleep 1

  loop do
    puts "Going forward..."
    motor.forward
    sleep 3
    puts "Stopping..."
    motor.stop
    sleep 2
    puts "Going backward..."
    motor.backward
    sleep 3
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
artoo-arduino-1.4.4 examples/dc_motor_switch_h-bridge_2_pins.rb
artoo-arduino-1.4.3 examples/dc_motor_switch_h-bridge_2_pins.rb