Sharp IR Detector (with Orangutan X2)

We are using the Orangutan x2 with VNH3 and display

We want to use a Sharp IR detector. The output is analog. How do I convert the output to a digital value, display, and use it to determine the next action


The X2’s main microcontroller (the ATmega644) has a hardware module that acts as an analog-to-digital converter (ADC). I strongly suggest you read through the ADC section of the mega644’s datasheet to help you better understand how it works.

You need to connect the output of your sharp distance sensor to one of the mega644’s analog inputs (any of the port A pins can be configured as analog inputs, though you should avoid using A6 and A7 since those are jumpered to the battery voltage level and user potentiometer by default), and then you need to configure the ADC module so that it will perform the desired conversion on the desired input. The X2 test code (located under the resources tab of the X2 product page) has function called motorsTest() that performs an analog-to-digital conversion on the output of the user potentiometer on analog input ADC7 (pin A7). It then sets the motor speeds based on the conversion result, and it displays the result on the LCD.

Hopefully this will be enough to get you started. Please ask if you have further questions.

- Ben