ChipKIT Parking Obstacle Sensor

Introduction: ChipKIT Parking Obstacle Sensor

I've always thought it would be nice to have a car with a parking sensor. I don't want to spend that kind of money until I pay off my student loans. However I do have the materials to make one myself thanks to a class I took on microcontrollers. Part of my motivation is that my car doesn't make parking particularly easy. The back end is tall and it doesn't extend out very far so I'm usually too far or too close.

This project will show you how to build your own parking obstacle sensor for your car.

This obstacle sensor shows the distance in inches, cm, or mm depending on the "units" variable you can change in the code. It also displays between 0 to 16 bars in the bottom indicating 0 to 255 inches. The sonar module can only detect between 6 and 255 inches. Any less than 6 will show as 6 and any more than 255 will display as 255.

Step 1: Tools and Materials

Step 2: Initial Testing

Test the hardware first to make sure it works and you have the pin selections right. To do this you will need MPIDE. I had used my board with MPLAB X IDE previously so I needed to reinstall the bootloader on the MX4 before I could use it with MPIDE. If you have a fresh board you will not have to do this.

Now download the example project for the PmodCLS LCD screen here. Get the one under MPIDE and follow the README contained within. Open the example project CLSDemo under CLS and upload it to the board. If all the jumpers are in the right places the program will run and show the screen you can see in the first picture.

note: If you get the error indicating you need Bounce.h get it from here and add it to your libraries.

To run the example project for the MAXSonar module on an MX4 you'll need to change a few pin definitions in the program.

#define ANpin 48

#define RXpin 49

#define PWpin 50

Get the example installed and change the pins to the following and plug the sonar module into the top row of JH. If you upload your revised example project and open the Serial Monitor window in MPIDE you should see the same output as you see in the Serial Monitor.

With that taken care of we can put the obstacle sensor together and program it.

Step 3: Hardware Layout

I wanted this project to be as portable as I could make it given the size of the MX4. The screw holes on the LCD line up perfectly with the left or right screw holes on the MX4 so I decided to screw it to the top using standoffs. They were a touch too short so I added washers on the top and bottom of the standoffs as you can see in picture 2.

To stop the LCD cable sticking out the side bend the Pmod Header pins around. Use a pair of pliers to bend all of the pins up. It doesn't take very long.

The battery will be attached to the back using velcro in a later step.

Step 4: Software

Download the MyRangeDisplay folder and open MyRangeDisplay.pde with MPIDE. Upload this to your MX4 board and it should display the distance from the sonar module to the nearest detectable obstacle. I only have one sensor displaying on the screen but when I get another one I will modify it to show both on the same screen. It might be more cramped on the display but it will help when backing towards something at an angle.

The most up to date version of this program will be on my GitHub here. I know I'll have to tweak the program to make it more to my liking.

Step 5: Check Wire Orientation

Before this step double check the length of your Cat5e patch cable. Run it all the way from the trunk, through the seats and up to where you want it on the dash and mark where you want to cut each end. I like the cable to be out of the way so I ran mine in the seams of my seats and under rugs. It is hardly visible but it uses up more cable.

  1. Cut the short Pmod 6-pin cable in the middle and strip the outer casing back a bit on both halves.
  2. Strip, twist, and tin each wire on both halves. (you can cut the wires for PWM and Analog signals. If pins 1 and 2 are Vcc and GND respectively pins 3 and 6 would be the ones to cut. Always put the edge of the connector with the three white dots closest to Vcc and you won't plug them in backwards.)
  3. Repeat steps 1 and 2 for a second Pmod cable if you want to add another sensor.
  4. Label the first and second cable accordingly to avoid mixing up the left and right sensor later.
  5. Cut the Cat5e patch cable at the ends where you marked it earlier and clean up the ends by stripping, twisting, and tinning the wires.
  6. Test that the colors of your Pmod cable match up to mine.
    1. Set multimeter to beep when the probes are electrically connected
    2. Write down what order the colors are in starting with the pin closest to the white dots. (Could be on the left or right of the connector)
  7. If your Pmod colors are in the same order that mine are in you can use the table in image 4 to connect the wires just like I did.
  8. If yours don't match up to mine write up your own table to make sure you are getting the same pin order on both ends.
  9. Tin the wires at this point to make soldering easier.

Step 6: Wire Extension

Attach Cat5e wires to the two Pmod cables on the microcontroller end. (images 1-5)

  1. Cut and slide the 1/4 inch heat shrink tube over the outside of the Cat5e cable.
  2. Cut and slide the 3/32 inch heat shrink tube over the first wires you will solder.
  3. Solder the matching wires together.
  4. Shrink the tubing around the individual wires.
  5. Repeat steps 2 through 5 with all 8 of the wires. (4 per Pmod 6-pin cable)
  6. Shrink the 1/4 inch heat shrink tube over the bundle of wires.

Attach Cat5e wires to the two Pmod cables on the sensor end. (images 6-10)

  1. Strip the Cat5e cable outer sheath enough so half of the wires can reach the left side of your bumper and half can reach the other half. (picture 6)
  2. Unravel the solid color wires from the white striped wires.
  3. Braid the solid colors with each other and the white striped wires with each other. This doesn't have to be neat just enough so they don't come undone in your trunk.
  4. Repeat steps 1 through 6 that you did for the microcontroller end of the cable on the sensor end. Except use two 1/4 inch heat shrink tubes, one around each wire bundle end.

Step 7: Field Testing

Check your setup to see if it works and you haven't crossed any wires. You don't need to do this on your car. The tape holding my sensor gave out and made it point sideways. If I had kept trying this out I might have bumped into the garage door.

Step 8: Velcro Time

Sensor velcro

  1. Cut a square of velcro the size of your sensor.
  2. Place the hook side of the velcro on the car making sure to clean the area first. The fuzzy side will hold onto more water and will likely not last as long on the outside of your car.
  3. Place the fuzzy side of the velcro on your sensor. Press firmly and it will stick well to the circuit board.
  4. Repeat steps 1-3 if you have a second sensor. If you're using two sensors place one on either side of your bumper but still facing backwards.

Battery velcro

  1. cut a square of velcro about the size of your battery holder and secure your battery holder with it.

Step 9: Conclusion

If I were to do anything differently it would be to use a chipKIT MX3 instead of the MX4. The MX3 is smaller, which makes making an enclosure easier. I think I'll wait to get an MX3 to make an enclosure that fits my car. I have the perfect space but it's a little awkward. I'll be looking around for a container that fits that space.

This was my first instructable and I had a lot of fun making it. If you have any comments, questions, or how your build went I would love to hear about it so leave a comment down below.

Be the First to Share


    • Fiber Arts Challenge

      Fiber Arts Challenge
    • Backyard Contest

      Backyard Contest
    • First Time Author Contest

      First Time Author Contest



    6 years ago

    I've considered this idea before because I'm blind in eye and lack the depth perception that other people have but the thing that concerns me here is making something that that is rugged enough to handle rain, snow storms and salt - that thing called weather.
    I would love to see articles on how this sensor could be protected in the real world.

    Second comment, a smaller system is definitely possible, an Arduino UNO, Adafruit's Boarduino or anything similar will talk to an ultrasonic distance sensor easily. Ultimately, it could be reduced to a microprocessor chip, capacitors and a crystal. Of course, that's beyond the scope of this, you made simple for anyone to do.

    DroneBot Workshop
    DroneBot Workshop

    Reply 6 years ago

    Very nice Instructable, but I also have concerns about how weatherproof this would be (I'm in Canada where right now the snow is melting and the back of my car is covered in slush).

    One thought is to build it with an infrared obstacle sensor instead of an ultrasonic one, it should be a lot easier to make that weatherproof. Of course it would still have to be cleaned periodically. Perhaps it could be mounted in a taillight, infrared light should have no problem passing through the typical red lens on those.

    Great work, and certainly food for thought!


    6 years ago

    This is awesome! Especially for all of us who don't have back-up cameras!! Thanks for sharing. Can't wait to see what you create next!!