Page 1 of 1

Python

PostPosted: Thu Oct 30, 2014 9:19 am
by drx
I really enjoyed building and playing with the Pi-camera-robot and have added the ultrasonic sensor. However I am very much a beginner and am a bit confused about the control scripts (eg the sensor example). Why is it that the script runs fine from command line but gives error messages if I try to run it through Python as a module? I also notice that some of the syntax in the script is slightly different to my VERY limited experience of Python, why is this? I have started playing with the script to try and modify the behaviours and its become a bit of a stumbling block. Thanks in advance for any reply!

Re: Python

PostPosted: Mon Nov 03, 2014 11:20 am
by Alan
Hi there,

First of all, welcome to the forums :), and sorry for the delayed reply.

Can you post an example of the script that's giving you error messages? I might be able to provide some insight. Also, what syntax differences are you seeing? Python does offer multiple ways of doing the same thing in some areas, so it may just be my particular coding 'style' that you're seeing. ;)

Regards

Alan

Re: Python

PostPosted: Wed Dec 03, 2014 12:16 am
by drx
Looked at again and it was a few misunderstandings on my part and a difference in the print statement between python 2 and 3. As a separate question (sorry to muddle the threads) I have been thinking of using the robot to monitor my dogs, initially just so that when they start barking it takes a photo. Do you have any suggestions for a good sound sensor?

Re: Python

PostPosted: Wed Dec 03, 2014 6:21 pm
by Alan
Hi there,

I don't know of any specific sensors for this task, but I would say that I good way to start might be with a simple microphone, and then just monitor volume leves with the pyalsaaudio library.

Best of luck, would be interested to know how you get on.

Regards

Alan