EasyManuals Logo

Arduino Pro Mini User Manual

Arduino Pro Mini
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 #276 background imageLoading...
Page #276 background image
maik> ruby analog_reader.rb /dev/tty.usbmodem24321
a0: 496
a0: 456
a0: 382
^Canalog_reader.rb:27:in `gets': Interrupt
from analog_reader.rb:27
Using Ruby to access an Arduino is a good choice because you can fully
concentrate on your application. All of the ugly details you have to deal with
in other programming languages are well hidden.
Python
Python is another dynamic programming language you can use to quickly
create Arduino clients. For programming a serial port, download and install
the pyserial library first.
5
There is a special installer for Windows, but usually
its sufficient to install it like this:
maik> python setup.py install
After youve installed pyserial, you can use it to create a client for our analog
reader sketch:
/SerialProgramming/Python/analog_reader.py
import sys
Line 1
import time
-
import serial
-
-
if len(sys.argv) != 2:
5
print "You have to pass the name of a serial port."
-
sys.exit(1)
-
-
serial_port = sys.argv[1]
-
arduino = serial.Serial(
10
serial_port,
-
9600,
-
serial.EIGHTBITS,
-
serial.PARITY_NONE,
-
serial.STOPBITS_ONE)
15
time.sleep(2)
-
while 1:
-
arduino.write("a0\n")
-
line = arduino.readline().rstrip()
-
print line
20
5.
http://sourceforge.net/projects/pyserial/files/
report erratum discuss
Serial Communication Using Various Languages 263
www.it-ebooks.info

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

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

Arduino Pro Mini Specifications

General IconGeneral
BrandArduino
ModelPro Mini
CategoryMotherboard
LanguageEnglish

Related product manuals