First play with the matbotix sonar sensor.

Today, I finally got to the local electric store before they had closed. I had to get a soldiering iron and some pcb headers. I soldiered the headers to the sonar sensor, and plugged it into my breadboard. This setup is very nasty at the moment, but i wanted to know if this was going to work for me. I have been doing a little reading and found a few useful links. The code from the playground site;

Info from a matbotix guy (and filtering).

The code i modified and used for my MB7060:

//Feel free to use this code.
//Please be respectful by acknowledging the author in the code if you use or modify it.
//Author: Bruce Allen
//Date: 23/07/09

//Digital pin 7 for reading in the pulse width from the MaxSonar device.
//This variable is a constant because the pin will not change throughout execution of this code.
const int pwPin = 7; 
//variables needed to store values
long pulse, cm;
void setup() {
  //This opens up a serial connection to shoot the results back to the PC console
void loop() {
  pinMode(pwPin, INPUT);

  pulse = pulseIn(pwPin, HIGH);
  cm = pulse/58;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s