-5

I have a project about my Robotics class. I will make a maze robot that can exit from a simple maze. I have Sharp Infrared Sensor to read distance from wall while my robot is traveling. Ok, I projected my algorithm, but firstly, I just need to read distance value from my sensor. I don't know how can I read it, with which code of C, or do I have to #include.. something at the beginning of my program. I searched lots of things on net, but I found nothing except datasheet of this sensor. Please,I'm waiting for helps from the ones who did such kind of projects before. I really need help. I must submit my project in 2 days.

Sorry my grammer mistakes. Thanks in advance.

Jonah
  • 11
  • 1
  • 4
  • 5
    **Two days**?? To program a robot to navigate a maze? And you're at the "do I need an #include or something" level? You're completely out of luck, and **completely** out of your depth. Ask your professor for help or guidance. – user229044 Jan 03 '13 at 14:46
  • 3
    Step 1: Connect sensor to uC as specified in the sensor's datasheet. Step 2: Write program who uses data from the sensor to navigate maze. This sort of thing is not simple if you don't know a lot about electronics and programming. I would say a good step three would be to pay attention and not postpone projects like this untill the last minute. – Kenneth Jan 03 '13 at 14:47
  • [This page](http://www.acroname.com/robotics/info/articles/sharp/sharp.html) talks a bit about ranging sensors from Sharp, perhaps that helps you if your sensor looks like any of those shown. – unwind Jan 03 '13 at 14:58
  • 1
    It would also be rather helpful to know what uC you using. – marko Jan 03 '13 at 15:01

1 Answers1

3

Post a link to the Datasheet. Also describe how the sensor is connected to your robot. The question is vague as it stands.

Without knowing much, I would assume the sensor has a physical interface to the micro controller you are using for your robot (i.e. I2C, Serial, etc). I would also assume the sensor has some basic messaging protocol to use over this physical interface. It is possible it also has an API written that implements this messaging protocol.

If it already has a C API written, you should only need to include the proper API files, then write the C code for your micro to use the functions from the API to read from the sensor.

If it does NOT have a C API already written, you will need to use the functions from your micro that are specific to the physical interface and implement the messaging protocol yourself. For example, if the physical interface is I2C, you would use your micro's I2C library and send the proper message pieces to the sensor in order to receive the message for distance. You then need to write parsing logic for any messages you receive.

This will be easier if the API is already written. In any case, it sounds like you should have started sooner than 2 days before it is due :)

trh178
  • 11,228
  • 5
  • 28
  • 37