DEV Community

Nima
Nima

Posted on

Relaxing Arduino's work with Ruby

One of the ways to break into the system is to use bad USBs and to use bad USBs you must know Arduino and the syntax of Arduino language is a bit difficult. But don't worry, we solved this problem to some extent, you can use 'rubyino' library and convert your ruby codes to arduino codes. In this method, you don't need to learn Arduino codes and you only need Arduino IDE to upload the codes. Let's get started.

how to install ?

  • install with gem
gem install Rubyino
Enter fullscreen mode Exit fullscreen mode
git clone https://github.com/nimacpp/rubyino.git
cd rubyino
gem build rubyino.gemspec
gem install rubyino*.gem
Enter fullscreen mode Exit fullscreen mode

Rubyino's functions

first you need include gem and then set value for it like this :

require "Rubyino"
app = Rubyino.new("namefile")
Enter fullscreen mode Exit fullscreen mode

now you can work with Rubyino

functions on Rubyino

delay(timer sleep) :

app.delay(500)
Enter fullscreen mode Exit fullscreen mode

print(print keyboard) :

app.print "hello world"
Enter fullscreen mode Exit fullscreen mode

Enter(Enter key) :

app.enter
Enter fullscreen mode Exit fullscreen mode

Window or cmd key + key :

win_pls "r" # win+r
Enter fullscreen mode Exit fullscreen mode

and for translate codes to Arduino need ter function like this :

app.ter
Enter fullscreen mode Exit fullscreen mode

one Example for know that :

require "rubyino"
app = Rubyino.new("file")
app.delay(5000)
app.win_pls('r')
app.print "echo hello world"
app.enter
app.print "ls -a"
app.ter
Enter fullscreen mode Exit fullscreen mode

save it and run it . script will create a file named file.ino for you .
Please open the file with the Arduino ide program and press the upload button to upload the script to the arduino

Top comments (0)