Skip to content

bachmarc/ev3dev_ruby_stretch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ev3dev ruby binding for LEGO Mindstorms EV3

ev3dev_ruby is a gem to controll sensors and motors on EV3 using Ruby on ev3dev OS.
ev3dev OS is a Debian Linux-based operating system for LEGO Mindstroms EV3.

Install ev3dev OS

See ev3dev OS website

Install ev3dev_ruby on EV3

SSH remote access to the EV3 from PC

(default ev3dev user; robot, password; maker)

then

robot@ev3dev:~$ sudo apt-get update
robot@ev3dev:~$ sudo gem install ev3dev_ruby

Run examples

1. Copy the examples to the /home/robot directory in ev3dev from PC.

(for OS X user; )

$ scp -r /Users/xxx/Downloads/ev3dev_ruby-master/examples [email protected]:/home/robot

2. Run the program

There are two different ways to run the program.

A. Remote access from PC

robot@ev3dev:~$ cd /home/robot/examples
robot@ev3dev:~$ cd motor
robot@ev3dev:~$ ruby midiummotor.rb

B. File Browser on EV3

1. Add execute permission
robot@ev3dev:~$ cd /home/robot/examples
robot@ev3dev:~$ cd motor
robot@ev3dev:~$ ls -l
...
-rw-r--r-- 1 robot robot  474 Jan 18 16:18 midiummotor.rb
...
robot@ev3dev:~$ chmod +x midiummotor.rb
robot@ev3dev:~$ ls -l
...
-rwxr-xr-x 1 robot robot  474 Jan 18 16:18 midiummotor.rb
...
2. File Browser

Select the program and push the center button on EV3.

irb

You can also run programs using irb.

robot@ev3dev:~$ irb
irb(main):001:0> require 'ev3dev'
=> true
irb(main):002:0> mm = Ev3dev::Motor.new 'B'
=> #<Ev3dev::Motor:0x193890 @device_path="/sys/class/tacho-motor/motor0">
irb(main):003:0> mm.device_path
=> "/sys/class/tacho-motor/motor0"
irb(main):004:0> mm.driver_name
=> "lego-ev3-l-motor"
irb(main):005:0> mm.address
=> "outB"
irb(main):006:0> mm.commands
=> "run-forever run-to-abs-pos run-to-rel-pos run-timed run-direct stop reset"
irb(main):007:0> mm.stop_commands
=> "coast brake hold"
irb(main):008:0> mm.duty_cycle_sp 100
=> #<Ev3dev::Motor:0x193890 @device_path="/sys/class/tacho-motor/motor0">
irb(main):009:0> mm.command 'run-forever'
=> #<Ev3dev::Motor:0x193890 @device_path="/sys/class/tacho-motor/motor0">
irb(main):010:0> sleep 3

=> 3
irb(main):011:0> mm.command 'stop'
=> #<Ev3dev::Motor:0x193890 @device_path="/sys/class/tacho-motor/motor0">
irb(main):012:0>

ev3dev API

(Also checkout examples)

EV3 Devices

The EV3 device below are not supported yet.

More Info

About

ev3dev ruby binding

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%