line avoiding maze with object retrieval and deposit- MiniBloq and Sparkiduino

Hi 🙂

A few days ago I posted about the way Sparki can sense lines, or changes underneath him:

https://ashbotandsparki.wordpress.com/2015/06/26/how-does-sparki-sense-lines/

Here is a program that makes use of this information, including the potential flaws.

In this program Sparki is intended to move forward until he reads a change in the reflected light underneath (so reaches a darker surface) and then turn 90 round the corner in the opposite direction. So if the sensor on the far left detected change the Sparki would turn right and vica versa. This leaves the middle sensors open for picking up an object with the grippers and depositing an object at the end of the maze.

Here is a screenshot of part of the MiniBloq code (it wont fit):

Untitled12

And here is the arduino version:

#include <Sparki.h>

void setup()
{
	float threshold = 500;
	while(true)
	{
		int lineCenter = sparki.lineCenter();
		int edgeLeft = sparki.edgeLeft();
		int edgeRight = sparki.edgeRight();
                float threshold = 500;
		sparki.servo(0);
		sparki.RGB(0,255,0);
		if((edgeLeft<threshold))
		{
			sparki.servo(90);
			delay(2000);
			sparki.RGB(0,0,255);
			sparki.moveRight(90);
		}
		else
		{
		}
		if((edgeRight<threshold))
		{
			sparki.servo(-(90));
			delay(2000);
			sparki.RGB(0,0,255);
			sparki.moveLeft(90);
		}
		else
		{
		}
		if((edgeLeft>threshold))
		{
			sparki.moveForward(0);
		}
		else
		{
		}
		if((edgeRight>threshold))
		{
			sparki.moveForward(0);
		}
		else
		{
		}
		if((lineCenter<threshold))
		{
			delay(1000);
			sparki.moveForward(3);
			sparki.gripperClose();
			delay(4000);
			sparki.gripperStop();
			delay(2000);
			sparki.RGB(255,0,0);
		}
		else
		{
		}
		if(((edgeRight<threshold)&&(edgeLeft<threshold)))
		{
			sparki.gripperOpen();
			delay(4000);
			sparki.gripperStop();
			delay(2000);
			sparki.RGB(0,0,255);
			sparki.beep(540, 1000);
			sparki.moveBackward(3);
			sparki.moveLeft(180);
		}
		else
		{
		}
		delay(2000);
	}
}

void loop()
{
}

Here is a video of Sparki completing a maze by staying inside the lines:

https://drive.google.com/file/d/0B6y9ITteBcqLLThlN3JMZElIYm8/view?usp=sharing

And finally a picture of the awesome bot getting ready to start the maze

DSC_8101

Let me know what you think 🙂 🙂

Advertisements

5 thoughts on “line avoiding maze with object retrieval and deposit- MiniBloq and Sparkiduino

  1. Awesome! The robot got to the finished line and reached the goal. The codes are great as the initial draft, could use some improvements. But after seeing the video, you starting off from a great point.

    Liked by 1 person

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