Sensor data

If you need technical help with anything you've bought from Dawn Robotics, please post here.

Sensor data

Postby kevcook » Sun May 24, 2015 5:25 pm

I've managed to get a Sharp infrared (analogue) sensor and it works according to the sensor example. However I want to just get this data on it's own. I'm lost. I've tried analogRead() etc but cannot seem to get it. I need some help with the code to (a) get the data from A2, (b) display the data, (c) the code to compare the data to a set variable. i.e if A2 reading > than 200 then Action etc etc. This is for use in an object collision python program. If any one could even direct me to where this is clearer than currently shown in the camera robot tutorial which displays ALL sensors in a loop.
I appreciate this is pretty basic stuff.
kevcook
 
Posts: 16
Joined: Mon Apr 13, 2015 2:23 pm

Re: Sensor data

Postby danijazz » Mon May 25, 2015 4:24 pm

There are several ways you could do this. One way is to take the robot_sensor_test.py and copy it. Comment out everything not needed and use. data[0] is A0, data[1] A1 etc.
while True:

miniDriver.setSensorConfiguration( sensorConfiguration )

miniDriver.update()
sys.stdout.write ("{0} ".format(miniDriver.getAnalogReadings().data[2]))
sys.stdout.flush()
time.sleep( 0.1 )

To do the comparison you could use if (miniDriver.getAnalogReadings().data[2] > 200)
danijazz
 
Posts: 7
Joined: Sun Aug 31, 2014 5:06 pm

Re: Sensor data

Postby kevcook » Mon May 25, 2015 6:40 pm

Thanks alot. Very useful and makes sense of it all! Got it working now (well best I can!), just need to flesh it out and tidy it up.
Thanks again.
kevcook
 
Posts: 16
Joined: Mon Apr 13, 2015 2:23 pm


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 0 guests