HRXL-MaxSonar 7366 Arduino with Serial

I really struggled with getting the new 10 Meter HRXL-MaxSonar to work with Serial.  The Pulse width seemed very inaccurate, and the voltage I had to take 100 samples and average them together, but the Serial was the ticket. The only problem…the Arduino UNO dosen’t have any accessible Serial pins when working with the computer and the arduino and my laptop.

The Radio Shack  The Shack in my town is not very good, they have air horns and 2 LEDs, and cell phones, but anything for the hobbist, no not really.  Luckily it’s mother’s day weekend and The Radio Shack The Shack where my Mom lives carries Arduino Mega! It was excellent! I was able to get one to test…I was excited and brought it home!  BAM , garbly text on the console. I did a little more research and found out that I actually needed an inverter, so I was stuck again. I have this project due to my boss in 2 weeks and I am stuck.  So I thought last night I would do some digging into the Arduino library and see if there is anything I could do, and there, next to all the other innocent libraries, I found it! “SoftwareSerial.” This library allows you to use your digital pins and create a software inverter.  The best part–it actually works and works really well!  There is one tradeoff, you can’t read more the one Serial at a time, but WHO CARES, I no longer have to deploy the mega.  This particular project is stuffed into an ip65 box, so space is limited.


SoftwareSerial mySerial(10, 11,true); // RX, TX, true sets the inverter
void setup()  
  // Open serial communications and wait for port to open:
  // set the data rate for the SoftwareSerial port
void loop() {
  int index = 0;
  boolean startreading = false;
  char in[6];
  in[5] = 0;
  while(index < 3){
      byte incoming =;    
      if(incoming == 'R') {
        startreading = true; 
      } else if(startreading) {
        in[index++] = incoming;
  Serial.print("In: ");
  Serial.print(" ");
  int i = atoi(in);
  long inches = i/25.4;

Leave a Reply

Your email address will not be published. Required fields are marked *