Giter VIP home page Giter VIP logo

ev3dev_ruby's Introduction

ev3dev ruby binding for LEGO Mindstorms EV3

ev3dev_ruby is a gem to controll sensors and motors on EV3 using Ruby.

  • ev3dev version; ev3dev-jessie-2015-12-30 or later

Install ev3dev_ruby on EV3

SSH remote access to the EV3 from PC

(default ev3dev user; robot, password; maker)

then

robot@ev3dev:~$ sudo gem install ev3dev

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

These EV3 devices below are not supported yet.

More Info

ev3dev_ruby's People

Stargazers

Kentaro Matsuura avatar Fly Chang avatar Dániel Vámosi avatar Quake Wang avatar  avatar elrrrrrrr avatar liguang2080 avatar Samwise Wang avatar Liang Cai avatar momo avatar Steve Chan avatar tony avatar

Watchers

Quake Wang avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.