Adding sensors IR 3pi (resolved)

Hello , I need some help on the 3pi , I would put two IR sensors.
I will use the ports ( PD0 ) and ( PD1 ) , but not know WHAT put on schedule.

If it were to be so ARDUINO

[code]pinMode (12, INPUT ) ; …


if ( digitalRead (12) == HIGH) {
do something …
}[/code]

In 3pi not worked , it would be something like the analog

but accurate digital input (0 or 1).

I searched several places and not found .

Thank U.

Att . Wesley Thiago
ps: google tradutor , BRASIL. xD

Hello, Wesley.

I am sorry you are having trouble adding your IR sensors to the 3pi. You can get an idea of how to take digital readings from those pins by looking at the “digital1” example of the “Orangutan Digital I/O Functions” section of the “Pololu AVR C/C++ Library User’s Guide”, which we link to under the “Resources” tab of the 3pi’s product page. You can also find a description of the functions used in that example under the “Orangutan Digital I/O” section of the “Pololu AVR Library Command Reference”, which is also linked to under the Resources tab. If you have trouble using those functions, or have a specific question about them that is not covered in those guides, let me know or post what code you have tried, and I would be happy to help.

-Jon

[quote=“JonathanKosh”]Hello, Wesley.

I am sorry you are having trouble adding your IR sensors to the 3pi. You can get an idea of how to take digital readings from those pins by looking at the “digital1” example of the “Orangutan Digital I/O Functions” section of the “Pololu AVR C/C++ Library User’s Guide”, which we link to under the “Resources” tab of the 3pi’s product page. You can also find a description of the functions used in that example under the “Orangutan Digital I/O” section of the “Pololu AVR Library Command Reference”, which is also linked to under the Resources tab. If you have trouble using those functions, or have a specific question about them that is not covered in those guides, let me know or post what code you have tried, and I would be happy to help.

-Jon[/quote]

Thank you, you helped me a lot.

I took the test with this setting and it worked

[code]#include <pololu/orangutan.h>

int main()
{

set_digital_input(IO_D0, PULL_UP_ENABLED);

while(1)
{
    if(is_digital_input_high(IO_D0))     // Take digital reading of PC1.
    {
        set_motors(50,50); // PC1 is high, so drive PD1 high.
    }
    else
    {
        set_motors(-50,-50);   // PC1 is low, so drive PD1 low.
    }
}

}[/code]

Another question:
Using the same programming for the (PD1).

The input / output (PD1), has an LED that is on, and when I turn the IR sensor on this input, the LED is always on, but when I test sensor works correctly.
Its off this LED?
Disabling the pull-up ?

I am glad you got it working. The red LED is attached to pin PD1, so it will light whenever that pin is high. (This cannot be changed in software.) However, it should be safe to desolder the red LED if you do not need it.

By the way, to see how that LED is used on the 3pi, you can look at the simplified schematic, which we also link to under the Resources tab of the 3pi’s product page.

-Jon

Thanks for the help once again, doubts are resolved.

hug