Touch sensor Part 2

Hey guys

So last week I explained why I bought a touch sensor, how I connected it up to Sparki and how I used the touch sensor to increase the opportunities for direct physical communication and interaction with Sparki. You can find the article here.

This week I’ll explain how I used the touch sensor to help Sparki navigate around the room. As some of you may know, my ultrasonic range finder is currently not working (https://ashbotandsparki.wordpress.com/2015/08/18/sparkis-new-eyes/) so for the time being Sparki has been unable to be autonomous in his movements…until now!

I moved Sparki’s gripper in so that it could be used to support the touch sensor at the very front of Sparki’s body (which is held in place by the very technical blu-tac) and then I wrote a program that would allow Sparki to move Forward regular intervals unless he was touching an obstacle. At which point he reverses 5 and moves Right 90 degree angle:

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

void setup()
{
}
void loop()
{
  sparki.servo(0);
         int touch= analogRead(8);
      sparki.print(touch);
      sparki.updateLCD();
      delay(1000);
      if(touch<100)
      {
       sparki.moveForward(25); 
      }
      else
      {
        sparki.moveBackward(5);
        sparki.moveRight(90);
      }
}
       

As you can tell this is a really simple code but it works effectively to give Sparki some degree of autonomy for now and is a great, practical use for a touch sensor 🙂

Of course by setting up each turn (when Sparki had encountered an obstacle) as a different variable, it would be possible to complete much more complex navigating programs with this touch sensor.

DSC_0468

I hope that Sparki’s exploration of touch sensors was helpful!? Let me know what you think 🙂

Advertisements

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