Difference between revisions of "Programming electronics"
From ThorstensHome
(Created page with "Ok, I did my first steps to control an electro motor with arduino, today I bought myself a "learning package USB" from Franzis. I plug it into my computer's USB port and it...") |
|||
Line 2: | Line 2: | ||
I plug it into my computer's USB port and it appears as /dev/ttyUSB0. I can then use it to switch on and switch off an LED. | I plug it into my computer's USB port and it appears as /dev/ttyUSB0. I can then use it to switch on and switch off an LED. | ||
+ | |||
+ | Python program to play the note A (440 Hz): | ||
+ | <pre> | ||
+ | import serial, time | ||
+ | |||
+ | conn = serial.Serial('/dev/ttyUSB0', | ||
+ | baudrate=9600, | ||
+ | bytesize=serial.EIGHTBITS, | ||
+ | parity=serial.PARITY_NONE, | ||
+ | stopbits=serial.STOPBITS_ONE, | ||
+ | timeout=1, | ||
+ | xonxoff=0, | ||
+ | rtscts=0) | ||
+ | |||
+ | while True: | ||
+ | conn.setDTR(True) | ||
+ | time.sleep(1/880) | ||
+ | conn.setDTR(False) | ||
+ | time.sleep(1/880) | ||
+ | </pre> |
Revision as of 21:21, 8 June 2012
Ok, I did my first steps to control an electro motor with arduino, today I bought myself a "learning package USB" from Franzis.
I plug it into my computer's USB port and it appears as /dev/ttyUSB0. I can then use it to switch on and switch off an LED.
Python program to play the note A (440 Hz):
import serial, time conn = serial.Serial('/dev/ttyUSB0', baudrate=9600, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=1, xonxoff=0, rtscts=0) while True: conn.setDTR(True) time.sleep(1/880) conn.setDTR(False) time.sleep(1/880)