Hi!

I am going to use a pir and an ultrasonic sensor in the chest of Robyn

This is what I use in IDE

https://github.com/MyRobotLab/pyrobotlab/blob/master/home/Markus/TorsoS…

and it prints

169cm
1
152cm
1
157cm
1
178cm
0
185cm
0
 
so the sensors are working
 
I need some help to get this working in MRL

moz4r

8 years ago

Hi Markus !!

This s the function I use with the last MRL/mrlcomm. Thanks our friend calamity for the solution :

right=Runtime.create("i01.right", "Arduino")
right.setBoard("atmega2560")
right = Runtime.start("i01.right", "Arduino")
right.connect("COM4")
 
def publishPin(pins):
    for pin in range(0, len(pins)):
        print pins[pin].address, pins[pin].value
 
right.addListener("publishPinArray","python","publishPin")
right.enablePin(54,1) ->>> THE NUMBER 1 IS HOW MANY POLLS / SECONDS

 

post : http://myrobotlab.org/content/mrl-1742-analog-reader-correct-method

moz4r

8 years ago

Great ! about ultrasonnic maybe you can increase the number of pollings / seconds and and read the better value

Hi markus, you need to set the trigger and echo pin in the

at least i think this was it.

I don't understand something about sensors and mrl, I want to use the good method when I use them ( i just tested with succes hall effect sensors via enablepin array )

What is the difference between use the analog reader ( enablepin ) and embeded sensor reader ? ( I saw here a file like MrlUltrasonic.h )

The ultrasonic device does not return an analog value. It works by sending out a high frequency tone, and then listens for the sound to be returned ( bouncing back on an object ). So the reading is the time it takes from the sound to be sent away until it returns. Sound travels 300m/s. So if it takes 10ms for the sound to come back, the distance to the object is 3m.

That logic need to be in MRLComm, since the Ultrasonic sensor doesnt' measure that time. The pin just changes from low to high when the sound comes back.