Hello guys i wanted to try the wireless piano (first time experementing with MRL) thats posted on the website by Alessandruino but i c/p code to python, i've installed arduino and jfugue extensions on MRL but and i've set my Arduino Mega2560 to COM4, Bps 9600, data bits 8, parity none, stop bits 1, flow control none but when i try to upload the example code on the board it says:
296260 [python] INFO org.myrobotlab.service.Python - exec #file : JFugue.pingPiano.py import time #create a Serial service named serial jf = Runtime.createAndStart("jf","JFugue") serial = Runtime.createAndStart("serial","Serial") count = 0 if not serial.isConnected(): #connect to a serial port COM3 57600 bitrate 8 data bits 1 stop bit 0 parity serial.connect("COM4", 9600, 8, 1, 0) #have python listening to serial serial.addListener("publishByte", python.name, "input") def input(): global count newByte = int(serial.readByte()) #we have reached the end of a new line if (newByte == 10) : distanceString = "" while (newByte != 13): newByte = serial.readByte() distanceString += chr(newByte) distance = int(distanceString) print distance # count is used to avoid loop : one note couldn't be repeated if (distance < 20 and count != 1) : jf.play('C') count = 1 elif (distance > 30 and distance < 50 and count != 2): jf.play('D') count = 2 elif (distance > 60 and distance < 80 and count != 3): jf.play('E') count = 3 296289 [Thread-199] WARN class org.myrobotlab.framework.Service - startService request: service jf is already running 296290 [Thread-199] WARN class org.myrobotlab.framework.Service - startService request: service serial is already running 296291 [Thread-199] INFO org.myrobotlab.serial.SerialDeviceFactory - getSerialDevice COM4|9600|8|1|0 296291 [Thread-199] INFO org.myrobotlab.serial.SerialDeviceFactory - Loaded class: class org.myrobotlab.serial.gnu.SerialDeviceFactoryGNU 296291 [Thread-199] INFO org.myrobotlab.serial.SerialDeviceFactory - Got method: public org.myrobotlab.serial.SerialDevice org.myrobotlab.serial.gnu.SerialDeviceFactoryGNU.getSerialDevice(java.lang.String,int,int,int,int) throws org.myrobotlab.serial.SerialDeviceException 296297 [Thread-199] ERROR org.myrobotlab.service.Serial - could not get serial device 296298 [Thread-199] WARN class org.myrobotlab.framework.Service - attempting to add duplicate MRLListener {"outMethod":"publishByte""name":"python""inMethod":"input""paramType":"[Ljava.lang.Class;@23259fb6"}
The only variable i changed was COM3 to COM4, should i change anything else? i know the sollution must be easy and i feel really stupid :P Thanks in advance!!!
Works for me
Try restart the MRL and let the script start the processes
Welcome gseonr !
The Errors you are see are because you are running the script twice,
so it's trying to re-create the Services and re-open the serial port...
This should not be a problem though.
Some things to check.
1. Make sure the MRLComm.ino was loaded into your Arduino successfully - you can do this with MRL's Arduino service - but after an upload you should restart MRL. Or you can use the Arduino IDE to upload the script.
2. If things still don't work after that send a No-Worky to us.. and our "crack" team will look into the problem :D http://myrobotlab.org/content/helpful-myrobotlab-tips-and-tricks-0#noWorky
OH ! (just saw the connect) so there may be some confusion MRL needs MRLComm.ino loaded on your arduino..
The default connection parameters of the script are 57600, 8, 1, 0 - did you change this in MRLComm.ino ?
Default connection can be done without parameters e.g. serial.connect("COM4") in the Python
Curious why you want to connect at 9600 ?
And change your Avatar .. You are not scared gopher ! :D
Reply
Hello back and thanx for the instant reply!
To begin with, i once tried changing the bitrate to 57600 but i couldnt change it and also i'm not really sure about what it would happen if i increase it.
Secondly, well secondly i want to know how to change it because i cant do anything if i dont have the correct parameters :D
Cheers!
PS. Is there a "map" of which pins i have to use for the ultrasonic sensor? (I have the HC-SR04 and it has 4 pins)
hi gseonr, have you ever used
hi gseonr, have you ever used your sensor without mrl? what i mean is : have you an arduino sketch which is worky for your sensor?
It would be good to make it works just using the arduino first....
Test this arduino sketch and tell us if it works for you!!
using this script you should
using this script you should be able to read the distance in the arduino serial monitor
Hey
Hey man, thanks for the reply, i've used ultrasonic sensors a lot in my previous projects so i dont think that this is the part that i mess it up :P
this project is made by an
this project is made by an arduino sketch and a python script...i need to know if that arduino sketch works for you... thanks
tried
Just tried the arduino sketch, works just fine :)
To make ur life easier can u tell me in a few words what i have to do to make this project work? for example
1) load the sketch on arduino
2) C/p the python code to MRL
3) etc etc etc
Ya...now that we know arduino
Ya...now that we know arduino sketch works we are ready to take-off :D
1) load that arduino sketch in your arduino
2)modify the python script with your arduino com port
3) run the script
4) let us know :D
Done
So i just did it and this is the log:
The last line goes forever as long i dont stop it, and no sound is coming from my speakers nor does the python tab next to java tab show anything :(
Sovled!
I sovled issues with it! i just had to use ("COM4" 8 1 0) instead of the original ("COM4") i was typing, thanks guys!
Yay ! ... Sorry about the
Yay ! ...
Sorry about the confusion.. I thought you were using the Arduino service.. but I see in the script it is using the Serial service .. my bad :(
serial.connect("COM4") without any parameters connects at 57600 rate 8 data 1 stop 0 parity ...