# Baby-O and the Pololu IR Sensor

So I have 2 questions:

1. I wrote some simple code to have the baby o controll the direction and speed of 2 motors based on the input coming in form the sensor. I’m using the ADC to return a value of the voltage coming back across the pin from the IR sensor. but to test it first I decided to just run a voltage on the pin to make sure that my code was correct. So do I need to put the positive or negative line off my power supply on the pin (I’m using PC0 as my input). I’m guessing its the positive line and if so where do I put the negative line of the power supply, because no current is going to draw form just a positive line and thus no volatge. im also using a 9V battery as my source, could this be the problem, as in I need to use a voltage less than my reference voltage?

2. So to do this I’m using the Orangutan-lib v0.3 and I wrote the code for the ADc as follows.

x=analog8(PC0);

now this should return a value for x shouldnt it, or is there a different way I need to reference the pin. I have the Vref set up as the Vcc voltage (the +5V).

any ideas?

Thanks,

MichaelS

Hello, MichaelS.

The Orangutan I/O lines are not designed to handle more than 5.5 V, so tying an ADC pin to 9 V would be bad (you would probably burn out the pin). My recommendation is that you test the Orangutan ADC in one of two ways:

1. Use a battery whose voltage is less than 5 V (anywhere from 1 to 3 AAs or AAAs would work for this). Connect the negative side of the battery (or battery pack) to your Orangutan’s ground and connect the positive side to an ADC pin.

2. Use your Baby Orangutan’s Vcc to test its ADC. You can tap into Vcc via the through hole on the top of the board next to the M1 outputs (it’s labeled Vcc on the silkscreen on the back of the board). If you want to achieve an arbitrary voltage between 0 and 5 V, you can create a voltage divider whose input comes from Vcc and whose output goes to your ADC pin.

I can’t help you with your second question as I’m not very familiar with Orangutan-lib, but other people who frequent this forum should be able to assist you.

- Ben

By the way, which sensor are you using? I made the assumption that you were talking about the Sharp GP2Y0A21YK Distance Sensor we sell, but if you’re instead using our IR Beacon you don’t need to worry about analog voltages at all.

- Ben

ok so Ive totally misunderstood the way the IR beacon works then, so it outputs a digital signal, or and analog signal. That would by itself explain the problem.

The IR beacon outputs are purely digital.