boomerang bot

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

void setup()
{
  sparki.servo(0);
}
void loop()
{

  sparki.clearLCD();
  randomSeed(analogRead(1));
  int response1 = random(1,3);
  sparki.clearLCD();
  sparki.print(response1);
  sparki.updateLCD();
  delay(1000);
  sparki.moveForward(response1 *10);
  sparki.clearLCD();
  randomSeed(analogRead(1));
  int response2 = random(45, 90);
  sparki.clearLCD();
  sparki.print(response2);
  sparki.updateLCD();
  delay(1000);
  sparki.moveLeft(response2);
  sparki.clearLCD();
  randomSeed(analogRead(1));
  int response3 = random(1,3);
  sparki.clearLCD();
  sparki.print(response3);
  sparki.updateLCD();
  delay(1000);
  sparki.moveForward(response3*10);
  sparki.clearLCD();
  randomSeed(analogRead(1));
  int response4 = random(45, 90);
  sparki.clearLCD();
  sparki.print(response4);
  sparki.updateLCD();
  delay(1000);
  sparki.moveRight(response4);
  sparki.clearLCD();
  randomSeed(analogRead(1));
  int response5 = random(1, 3);
  sparki.clearLCD();
  sparki.print(response5);
  sparki.updateLCD();
  delay(1000);
  sparki.moveForward(response5 *10);
  delay(1000);
  sparki.moveLeft(180);
  delay(1000);
  sparki.moveForward(response5*10);
  delay(1000);
  sparki.moveLeft(response4);
  delay(1000);
  sparki.moveForward(response3*10);
  delay(1000);
  sparki.moveRight(response2);
  delay(1000);
  int home=(response1*10-1);
  sparki.moveForward(home);
  delay(1000);
  sparki.beep();
  sparki.clearLCD();
  sparki.drawString(10,1, "home");
  sparki.updateLCD();
  delay(2000);
  sparki.moveLeft(180);
}


This code is a really simple program that when executed combines free roaming with more intelligent navigation, allowing sparki to return to where he started (his home zone) irrelevant of the choices he makes.

DSC_0243_1

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