Hello Everyone, So I'm using the most recent Ubuntu OS, and am trying to figure out my options for communicating between the Due and Ubuntu. I've tried to use pyserial, but I've got nothing to work. I'm curious what other options exist, perhaps something in C, or bash scripting. Python seems to be the way to go, but like I said I've been able to get it to work. I keep getting a syntax error on import serial. Any help will be much appreciated.
I`m using the Debian image and Serial works on that . Are you using the Arduino gui program on udoo Ubuntu or are you programming the board via usb and a separate computer ?. I`m using pyfirmata which uses pyserial as a module , so I know that works. I had problem with a homemade rootfs and could not get the serial to work on that , But wasn`t getting any errors. Try making a serial test program and use the serial monitor built in to arduino .
Yeah, I'm using the gui on udoo. I've been considering changing the OS for a while now. Are you implementing Debian Wheezy, or just straight Debian? Also did you have to download pyfirmata, and if so where can I look into the install process? Thanks for your input, and hopefully I'n not asking too much.
Wheezy is the stable version and jessie is the unstable or testing version. I`m running this Wheezy image "udoo_quad_debian_wheezy_armhf_v1.1 " Sort of , you use pip . apt-get install python-pip then :- "pip install pyfirmata" and "pip install pyserial" , which it needs . This is my program which is controlling a RGB led , which is a Common Cathode led with the common to the 3.3 volt supply and resistors fitted to the other leads , which are on p13 , p12 , p11 . Being Common Cathode , logic 1 is off and logic 0 is on . Code: #! /usr/bin/python import commands , time , serial , sys #from pyfirmata import Arduino, util #from pyfirmata import * import pyfirmata off = 1.0 #board = Arduino('/dev/ttymxc3' ) board = pyfirmata.ArduinoDue('/dev/ttymxc3') digital_0 = board.get_pin('d:13:o') digital_1 = board.get_pin('d:12:o') digital_2 = board.get_pin('d:11:o') delay = .005 digital_0.write(1) digital_1.write(1) digital_2.write(1) # off time.sleep(1) while 1: digital_0.write(1) digital_1.write(1) digital_2.write(0) # green time.sleep(delay) digital_0.write(1) digital_1.write(0) # red digital_2.write(1) time.sleep(delay) digital_0.write(0) # blue digital_1.write(1) digital_2.write(1) time.sleep(delay) digital_0.write(0) # magenta digital_1.write(0) digital_2.write(1) time.sleep(delay) digital_0.write(1) # yellow digital_1.write(0) digital_2.write(0) time.sleep(delay) digital_0.write(0) digital_1.write(1) digital_2.write(0) #cyan time.sleep(delay)
Thank you very much for your help today. I'm going to image the OS tonight, but I have one last question. I'm assuming what you posted is your python script, and most of my programming experience is in Java. So I'm confused about the first line. What is its purpose? "#! /usr/bin/python"
The first line is a simple use python to run this script , also which version of python you want to use . The "#! /usr/bin/python" is use the default version , but I could have used "#! /usr/bin/python3" which you do the same for bash scripts "#!/bin/bash" Save have to type python ./myscript.py and just type ./myscript.py . My bit of java a know , I need to goggle like mad to do any thing with java