Designed by Tom Schaub is a widely used logo for the ruby programming language.
Sporting some flashy ruby icons, is the Scripting tab in the Arduino IDE. Upon startup, a listing of your ruby script files is generated from your Sketchbook directory.
Don't look, yet!
Of course there's no scripts in there, you need to crack open your ruby reference and create some. Once you do, you'll see how easy it is to automate repetitive tasks.
Hello_Arduino_World.rb code listing:
puts("Hello Arduino World")
File I/O
How about writing to a file from a ruby script? Well that's easy:
myFile = File.new("test.txt","w")
myFile.puts("Writing a line to a text file.")
myFile.puts("And Another.")
myFile.close()
Enjoy!
5 comments:
so does this mean that there is a ruby api for the arduino? what would i use this for?
@Ryan
Yes! The Ruby API will be able to command the IDE.
The Arduino Ruby API link is still being worked on, but the fundamental scripting framework now exists.
Omar's got a short list of implemented API calls, but you will be able to write scripts that look something like this:
Arduino.compile()
Arduino.upload()
myFile = File.new("Arduino_serial_log.txt","w")
while( Arduino.SerialAvailable() ) {
myFile.puts(Arduino.SerialRead())
}
myFile.close()
I'm really excited to see the API get traction over the next couple of releases!
@Chris
So the Ruby API is for interacting with the IDE, not necessarily for generating code that will compile for the Arduino, correct?
@ryan
From what I can tell, they are not running anything derived from the ruby code on the Arduino. By providing a ruby interface into the Arduino IDE, you can build things akin to build scripts (send a proprietary config to the device via serial, perhaps) and unit tests (verify that, whilst running, the Arduino performs in an expected fashion).
I know I'm a bit late to find this and add to the discussion, but in case you haven't already found it, you should definitely check out RAD (Ruby Arduino Developlment) which lets you write Ruby code that gets translated into Arduino code. It was written by my friend Greg Borenstein and I'm quite sure he would love to hear about your developments.
http://rad.rubyforge.org/
Post a Comment