EasyManuals Logo

Arduino uno User Manual

Arduino uno
311 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #275 background imageLoading...
Page #275 background image
communication from your applications logic. Have a look at the projects
examples to learn more about these features.
Ruby
Even dynamic languages such as Ruby give you instant access to your com-
puters serial port and to an Arduino connected to it. But before that, you
need to install the serialport gem:
maik> gem install serialport
Using it, you can connect to the Arduino in just 30 lines of code.
SerialProgramming/Ruby/analog_reader.rb
require 'rubygems'
Line 1
require 'serialport'
-
-
if ARGV.size != 1
-
puts "You have to pass the name of a serial port."
5
exit 1
-
end
-
-
port_name = ARGV[0]
-
baud_rate = 9600
10
data_bits = 8
-
stop_bits = 1
-
parity = SerialPort::NONE
-
-
arduino = SerialPort.new(
15
port_name,
-
baud_rate,
-
data_bits,
-
stop_bits,
-
parity
20
)
-
-
sleep 2
-
while true
-
arduino.write "a0\n"
25
sleep 0.01
-
line = arduino.gets.chomp
-
puts line
-
end
-
We create a new
SerialPort
object in line 15, passing it all the usual parameters.
After we sleep for two seconds, we start a loop and call
write
on the
SerialPort
object. To get the result back from the Arduino, we call
gets
, and then we print
the result to the console. Here you can see the program in action:
Appendix 3. Advanced Serial Programming 262
report erratum discuss
www.it-ebooks.info

Table of Contents

Other manuals for Arduino uno

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Arduino uno and is the answer not in the manual?

Arduino uno Specifications

General IconGeneral
Form factorArduino
CertificationRoHS, FC, CE
Processor model-
Processor frequency- MHz
Microcontroller modelATmega328
Microcontroller frequency16 MHz
DC input voltage7-12 V
Operating voltage5 V
DC current per I/O pin40 mA
Flash memory0.032 MB
Maximum internal memory- GB
SRAM (Static Random Access Memory)2 KB
EEPROM (Electrically Erasable Programmable Read-Only Memory)1 KB
Wi-FiNo
Number of analog I/O pins6
Number of digital I/O pins14
Weight and Dimensions IconWeight and Dimensions
Board dimensions53.4 x 68.6 mm

Related product manuals