Python Log Serial Data Interface
Pexpect is a pure Python Expect-like module. Pexpect makes Python a better tool for controlling other applications. Queues (FIFO) and stacks (LIFO) Python makes using.
• Now, save the text to the left as digital_piano.py, or whatever you want, ending in '.py'. (Note that this code was adapted from the tutorial: An Introduction to Tkinter.
Thanks!) Also, the code is shown in two images. The images, however, have some overlaps, so watch out for that. Finally, the first letters of the first three lines are i, f, and s, in case it was too hard to tell. • When you're done with that, execute the file. A window should pop up!
To use this, click a button and the note will play from the Arduino! • Also, an image of the final product is shown to the left. • Additional notes: If you had any trouble with these projects, go into the Python file and make sure that the path to the Arduino (currently /dev/ttyUSB0) is the path to yours. The path above only works for Ubuntu, and so you may have to change it around. Also, the piano is in its beta version, and has a few glitches. • Final note: If these projects interested you, look at the pySerial documentation that can easily be found via Google.
• Please go ahead and modify/tinker with these projects, and create your own. I have already created an amazing TVout application that prints off RSS feeds, and did it in about one day.
Statue Lil Eddie. Use this tutorial, and post your accomplishments here, at Make: Projects.
Here at I'm following a Robotics course. In the practical part of the exam we have to write some applications to operating some didactics robots we have (Rhino XR-4 and SCARA Robots). Each robot is connected to a Controller (Rhino Mark-4) which can be connected to a PC to send commands to the Controller in order to let the robots do things. The PC to Controller connection is a serial RS-232 connection. For the practical parts of the exams we need to write applications which, using the RS-232 communication channels, controls the movements of the robots.
The professor here suggested to use Java to implement the applications: unfortunately I found the API comm pretty complex in installation and configuration. I looked for different solutions. Surprisingly I found that with the module is a pretty intelligent solution! I've been able to install and use them (in both Linux and Windows) without problems at all (while my classmates had lot of problems with java and comm apis.).
Just follow any guide on the web to install Python on your system and then follow the installation guide. Using the pySerial apis is pretty simple: just have a look at the to have an idea of the apis it gives you.
A simple application I give you here a simple application which should let you understand how python serial apis are easy to use. The application is a simple serial terminal which you can use to send commands (and receive output) to a serial connected device. This is the application code: import time import serial # configure the serial connections (the parameters differs on the device you are connecting to) ser = serial.Serial( port='/dev/ttyUSB1', baudrate=9600, parity=serial.PARITY_ODD, stopbits=serial.STOPBITS_TWO, bytesize=serial.SEVENBITS ) ser.open() ser.isOpen() print 'Enter your commands below.
R nInsert 'exit' to leave the application.' After a lot of trying I got this to working #!c: Python27 Python.exe import sys, serial sys.stderr = sys.stdout ser = serial.Serial('COM27', 9600) print 'Content-type:text/html n n' print 'Real Time Temperature' print 'Real Time Temperature:' print ' print '%s'% (ser.readline()) print ' #''% ser.readline() # should be cgi.escape(ser.readline())! Ser.close() sys.exit(0) But this is refreshing the whole page. I want the latest value in my web page only. Secondly using print '' HTML CODE '' is giving me error 500 in my webpage (internal error) can you say why?
I am also working in python 2.6 and i want to send SMS to a mobile while my cell phone i.e. Nokia E-72 is connected to PC via Data Cable. The mobile is connected through the serial port and the code prompts the correct port as well and there is no error in the code but still the message is not being sent. Please help me. My code is as follows: import serial import time phone = serial.Serial() phone.baudrate = 38400 phone.bytesize = 8 phone.stopbits = 1 phone.xonxoff = 0 phone.rtscts = 0 phone.timeout = 0 phone.port = 4 #try different ports here, if this doesn't work. Phone.parity=serial.PARITY_NONE phone.open() print phone.portstr recipient = '+98' message = 'We did it!' Try: time.sleep(0.5) phone.write(b'ATZ r') time.sleep(0.5) phone.write(b'AT+CMGF=1 r') time.sleep(0.5) phone.write(b'AT+CMGS=' + recipient.encode() + b' r') time.sleep(0.5) phone.write(message.encode() + b' r') time.sleep(0.5) phone.write(bytes([26])) time.sleep(0.5) phone.readall() # print phone.readall(str) finally: phone.close().