Sha256: 31298180db96acda60132e2fd839ced571df0a98e802c963a7ceef07641cc651
Contents?: true
Size: 827 Bytes
Versions: 3
Compression:
Stored size: 827 Bytes
Contents
require 'littlewire' require 'artoo' #Circuit's breadboard layout here: http://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/breadboard-layout connection :digispark, :adaptor => :littlewire, :vendor => 0x1781, :product => 0x0c9f device :board, :driver => :device_info device :motor, :driver => :motor, :speed_pin => 1 # Use a PWM pin work do puts "Firmware name: #{board.firmware_name}" puts "Firmata version: #{board.version}" puts "Stopping motor..." motor.min # same as 'motor.stop' or 'motor.speed(0)' sleep 3 puts "Setting to maximum speed..." motor.max # same as 'motor.start' sleep 3 speed = 0 step = 50 every 3.seconds do motor.speed(speed) puts "Current speed: #{motor.current_speed}" speed += step if [0, 250].include?(speed) step = -step end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
artoo-digispark-0.4.0 | examples/dc_motor.rb |
artoo-digispark-0.3.0 | examples/dc_motor.rb |
artoo-digispark-0.2.1 | examples/dc_motor.rb |