Tutorial - Arduino LED Blinks
After completing this tutorial, you will be familiar with the most important concepts needed to play with Artoo and Arduino. If you are new to this world, don't worry; this tutorial should cover all you need to make it work.
- Before we start, make sure you have Ruby and Artoo installed , as well as Gort
- Make sure your Arduino device supports the Firmata protocol.
Follow this guide to Setup Arduino on Windows
Follow this guide to Setup Arduino on Mac OS X
Open a terminal and run the following command:
sudo apt-get install arduino
- Download Arduino IDE.
- Extract the downloaded package.
How to connect
First plug the Arduino into your computer via the USB/serial port. A dialog box will appear telling you that a new network interface has been detected. Click "Network Preferences...", and when it opens, simply click "Apply".
Install the artoo-arduino gem:
$ gem install artoo-arduino
Once plugged in, use the `gort scan serial` command to find out your connection info and serial port address:
$ gort scan serial
Use the `gort arduino install` command to install avrdude, this will allow us to upload firmata to the arduino:
$ gort arduino install
Once the avrdude uploader is installed we upload the firmata protocol to the arduino, use the arduino serial port address found when you ran `artoo connect scan -t serial`, or leave it blank to use the default address `/dev/ttyACM0`:
$ gort arduino upload firmata /dev/ttyACM0
Finally change code to the correct serial port
connection :arduino, adaptor: :firmata, port: '/dev/ttyACM0' # linux
Running the examples
If you installed the gem, you'll have to download the "Blink Led" example separately:
If you cloned the repository, you can access the example in the following folder: examples/blink_led.rb
Now, let's run the example:
$ ruby examples/firmata_blink_led.rb
The LED should be blinking in your arduino board.
Congratulations you have successfully completed this tutorial!