Forum >DFRobot Adjustable Infrared Sensor Switch
DFRobot Adjustable Infrared Sensor Switch

hi guys, hope every one had a good time over Christmas and new year, and to those who have yet to have new year...."happy new year"....
i have questions regarding the code for this ..DFRobot Adjustable Infrared Sensor Switch
[url=http://www.dfrobot.com/index.php?route=product/product&path=36&product_id=114]http://www.dfrobot.com/index.php?route=product/product&path=36&product_id=114[/url]
i noticed that there is a new kit out that makes use 3 of these sensors, DIY Remote Control Robot Kit (Support Android), i looked in the manual at the samples code and saw the object avoidance script.
-----
void setup()
{
Serial.begin(9600);
pinMode( A2 , INPUT);
pinMode( A3 , INPUT);
pinMode( A1 , INPUT);
int i;
for(i=6;i<=9;i++)
pinMode(i, OUTPUT);
}
void loop()
{
if (( !( digitalRead( A2) ) || ( ( !( digitalRead( A3) ) && ( !( digitalRead(A2) ) && !( digitalRead( A1) ) ) ) || ( !( digitalRead( A3) ) && !( digitalRead( A1) ) ) ) ))//read sensor from IR distence switch
{
back_off(240,240);
28 | P a g e
delay(1000);
Serial.print( "back" );
Serial.println("");
if (random( 1024 )>512)
{
turn_R(240,240);
delay(1000);
Serial.print( "random right" );
Serial.println("");
}
else
{
turn_L(240,240);
delay(1000);
Serial.print( "random left" );
Serial.println("");
}
}
else
{
if (( !( digitalRead( A3) ) || ( !( digitalRead( A2) ) && !( digitalRead( A3) ) ) ))//read sensor from IR distence switch
{
back_off(240,240);
delay(1000);
turn_L(240,240);
delay(1000);
Serial.print( "back and left" );
Serial.println("");
}
else
{
if (( !( digitalRead( A1) ) || ( !( digitalRead( A1) ) && !( digitalRead( A2) ) ) ))//read sensor from IR distence switch
{
back_off(240,240);
delay(1000);
turn_R(240,240);
delay(1000);
Serial.print( "back and right" );
Serial.println("");
29 | P a g e
}
else
{
advance(240,240);
delay(1000);
Serial.print( "go" );
Serial.println("");
}
}
}
}
So my question is..do i buy 3 of these sensors and add the above subroutines to my current sketch (same default names), flash and its runs? i understand that that the code in places may need to be tweeked ie speeds, but for autonomous roam, is the hardware needed, just the Adjustable Infrared Sensor Switch x3?
sorry for long post guys
i have questions regarding the code for this ..DFRobot Adjustable Infrared Sensor Switch
[url=http://www.dfrobot.com/index.php?route=product/product&path=36&product_id=114]http://www.dfrobot.com/index.php?route=product/product&path=36&product_id=114[/url]
i noticed that there is a new kit out that makes use 3 of these sensors, DIY Remote Control Robot Kit (Support Android), i looked in the manual at the samples code and saw the object avoidance script.
-----
void setup()
{
Serial.begin(9600);
pinMode( A2 , INPUT);
pinMode( A3 , INPUT);
pinMode( A1 , INPUT);
int i;
for(i=6;i<=9;i++)
pinMode(i, OUTPUT);
}
void loop()
{
if (( !( digitalRead( A2) ) || ( ( !( digitalRead( A3) ) && ( !( digitalRead(A2) ) && !( digitalRead( A1) ) ) ) || ( !( digitalRead( A3) ) && !( digitalRead( A1) ) ) ) ))//read sensor from IR distence switch
{
back_off(240,240);
28 | P a g e
delay(1000);
Serial.print( "back" );
Serial.println("");
if (random( 1024 )>512)
{
turn_R(240,240);
delay(1000);
Serial.print( "random right" );
Serial.println("");
}
else
{
turn_L(240,240);
delay(1000);
Serial.print( "random left" );
Serial.println("");
}
}
else
{
if (( !( digitalRead( A3) ) || ( !( digitalRead( A2) ) && !( digitalRead( A3) ) ) ))//read sensor from IR distence switch
{
back_off(240,240);
delay(1000);
turn_L(240,240);
delay(1000);
Serial.print( "back and left" );
Serial.println("");
}
else
{
if (( !( digitalRead( A1) ) || ( !( digitalRead( A1) ) && !( digitalRead( A2) ) ) ))//read sensor from IR distence switch
{
back_off(240,240);
delay(1000);
turn_R(240,240);
delay(1000);
Serial.print( "back and right" );
Serial.println("");
29 | P a g e
}
else
{
advance(240,240);
delay(1000);
Serial.print( "go" );
Serial.println("");
}
}
}
}
So my question is..do i buy 3 of these sensors and add the above subroutines to my current sketch (same default names), flash and its runs? i understand that that the code in places may need to be tweeked ie speeds, but for autonomous roam, is the hardware needed, just the Adjustable Infrared Sensor Switch x3?
sorry for long post guys
2012-01-04 23:54:49 Actually the IR sensors are normally using digital pins, for this particular setup we had to use the Analog pins since the digital pins were all used up(analog pins can behave like digital pins). But its best to use the digital pins if you wont be using other sensors.
The IR sensors were used for reverse sensing, and the ultrasonic was used for forward sensing, between these 4 sensors (both sensor are range finding) our robot achieved autonomous driving. Its really up to you how you want to achieve your goal. The quality of automation really depends on the coding more than on the hardware. The IR kit (IR receiver sensor and remote control) are not needed for autonomous control, its just an add-on feature.
the 3 IR sensors is enough to get a rough autonomous robot. No need to apologize. That's what we're here for.
Hector
The IR sensors were used for reverse sensing, and the ultrasonic was used for forward sensing, between these 4 sensors (both sensor are range finding) our robot achieved autonomous driving. Its really up to you how you want to achieve your goal. The quality of automation really depends on the coding more than on the hardware. The IR kit (IR receiver sensor and remote control) are not needed for autonomous control, its just an add-on feature.
the 3 IR sensors is enough to get a rough autonomous robot. No need to apologize. That's what we're here for.

2012-01-04 22:48:47 thanks for the reply Hector, ok just to clarify, i dont want to use any other sensors for the robots autonomous activities, just the 3 Adjustable Infrared Sensor Switches, as in the code pinMode( A2 , INPUT);
pinMode( A3 , INPUT);
pinMode( A1 , INPUT);..
i wasnt sure if the actually ir remote and recier was needed in part, but that is just for remote control? and not for object avoidence?
this first bit of the video shows the ping sensor moving (is that working with the ir sensors), and later on in the video its has the bot go foward back turn left for ward etc against a wall, the servo for ping was that being used?
im sorry i think im getting a lil confused on autonomous movement, the ping sensor and ir sensor do the same thing, range find??? just in different ways?? more sensors better it navigate , but it can work autonomous just using the 3 ir sensors? sorry
bkrause
pinMode( A3 , INPUT);
pinMode( A1 , INPUT);..
i wasnt sure if the actually ir remote and recier was needed in part, but that is just for remote control? and not for object avoidence?
this first bit of the video shows the ping sensor moving (is that working with the ir sensors), and later on in the video its has the bot go foward back turn left for ward etc against a wall, the servo for ping was that being used?
im sorry i think im getting a lil confused on autonomous movement, the ping sensor and ir sensor do the same thing, range find??? just in different ways?? more sensors better it navigate , but it can work autonomous just using the 3 ir sensors? sorry

2012-01-04 18:38:50 Hey Bkrause,
Yeah, for this section of code all you need is the 3 sensors. But you might need to tweak the way the function is processed depending on your needs, i.e. other sensors, movements, functions, etc...
Hector
Yeah, for this section of code all you need is the 3 sensors. But you might need to tweak the way the function is processed depending on your needs, i.e. other sensors, movements, functions, etc...
