Gleason Research released a new sensor to use with their Super Cricket microcontroller. It's an infrared distance sensor, which got me excited thinking we can start doing with the crickets what my younger students have been doing with NXT robots. When I tested them out I found that rather than outputting the actual distance reading, the sensor sends the microcontroller data similar to that of other cricket sensors--that is, a number from 0 to 255 that is inversely related to the intensity of environmental variable. So as the photocell sensor returns a higher number for lower light levels and a lower number for higher light levels, the distance sensor returns a higher number for close distances and lower for greater distances. You could work out some data points and calibrate the sensor that way for use in a conditional statement, but it would be nicer to have it return an actual distance. With the aid of this website, I was able to figure out a conversion formula that takes the raw data and outputs something close to actual centimeters. I used the formula given on the website but had to divide the result by 2. Its range is about 8 - 50 cm and it's more accurate from 8 - 15, becoming progressively wider than actual centimeters until up around 50 cm it's about 5 cm too wide. There is probably some fiddling I could do with the formula to lessen the slope a bit but for our purposes--making a functional educational robot--it should work well enough.
So here's a test program I put together:
setdistance ((2914 / (sensora + 5) - 1) / 2)
This will display the sensor data, converted to cm, on an LED display.