MiniBloq line following and gripper use

This was an awesome code to mess around with and taught me a lot.

Untitled

Initially I thought that Sparki could use his ultrasonic sensor to find out if there was an object in the path or not but I found that this then made it difficult for him to continue following the line (especially at corners) as the object would block the light, making the line sensor detect less light and conning Sparki into thinking he was still on the line.

This threw a spanner in my project but actually Sparki had 5, yes 5, line sensors, and so I decided I was willing to lose a bit of accuracy and instead of using the middle sensor to line follow, as this is the one that will be blocked by the object, I used an edge sensor to follow the line, keeping the line on the left or right of Sparki.

Even though this solves the problem, I decided instead to use the line sensors individually with commands for Sparki to pick up an object and drop an object depending on the line sensors readings. This worked really well and was fun to put together and play around with. It also meant that Sparki can pick up more than one object throughout the maze and provides a lot more freedom.

20150123_165834

here is the Minibloq generated code that I ended up with:

#include <Sparki.h>

void setup()
{
float threshold = 800;
float lineLeft = 0;
float lineRight = 0;
float edgeRight = 0;
while(true)
{
sparki.servo(0);
lineLeft = sparki.lineLeft();
lineRight = sparki.lineRight();
edgeRight = sparki.edgeRight();
if((edgeRight<threshold))
{
sparki.RGB(0,250,0);
sparki.moveForward(0);
}
else
{
sparki.RGB(250,0,0);
sparki.moveRight(0);
}
if(((edgeRight<threshold)&&(lineRight<threshold)))
{
delay(5000);
sparki.beep(440, 1000);
sparki.RGB(0,0,250);
sparki.gripperClose();
delay(2000);
sparki.gripperStop();
delay(1000);
}
else
{
}
if(((edgeRight<threshold)&&(lineLeft<threshold)))
{
delay(3000);
sparki.gripperOpen();
delay(2000);
sparki.gripperStop();
delay(1000);
}
else
{
}
delay(100);
}
}

void loop()
{
}

and here is a link to a video of Sparki running the completed program :

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

let me know what you think 🙂 🙂

Advertisements

One thought on “MiniBloq line following and gripper use

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