infrared obstacle detector

SKU072960 (1)
So my Sparki's ultra-sonic range finder is still broke unfortunately but I have purchased an infrared sensor that can be used for object detection. 

This brings back a sense of autonomy for Sparki as he can now navigate the rooms, making decisions about turns.

The following code allows Sparki to turn Right at very short intervals if his way forward is blocked:

#include <Sparki.h> // include the sparki library

void setup() {
 
 pinMode (3, INPUT); //Sensor output
}
void loop() {
  sparki.clearLCD();
sparki.print ("Sensor: ");
 sparki.println (digitalRead(3)); //print the sensor output
 sparki.updateLCD();
 delay (1500); 
 while (digitalRead(3) <0 )
 {
   sparki.moveForward();
 }
 while (digitalRead(3) >1 )
 {
   sparki.moveRight(10);
 }
   
 
}


Advertisements

2 thoughts on “infrared obstacle detector

    • well with the ultrasonic range finder Sparki was able to measure distances to obstacles (and then choose the “path of least resistance”) but the infrared range finder only provides a 1 or a 0 to the presence of an object; if an object is in the way it reads 1, if not 0 so Sparki cannot make intelligent decisions about which direction will be obstacle free for the furthest period. Having said that I think the sensing range on the infrared sensor is better than the ultrasonic range finder in that it can be altered to smaller or larger distances depending on your area and program, which means less for the atmega to process and less bytes in the program. I think the ultrasonic range finder is better overall and I would love to get my three pin one working but I cant so as an alternative the infrared sensor is my best bet 🙂

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s