Programming the Egg drawing robot

Scratch program for drawing squares on the egg.

The program to draw a grid of squares on the egg.

In order to program the egg drawing robot, a simple pair of loops are required. One draws the horizontal lines and the other is responsible for the vertical ones.

In this case, I’ve simply laid out a loop that:

  • Move to the left
  • Drop the pen
  • Move to the right
  • Lift the pen
  • Rotate the egg upwards slightly
  • Repeat ten times

Followed by:

  • Rotate the egg upwards to the start position
  • Move to the left
  • Drop the pen
  • Rotate the egg downwards
  • Lift the pen
  • Move the pen to the right slightly
  • Repeat ten times

In order to make the servos move over their required range, it was necessary to find out what the extremities of movement were – for example, how far can the pen be moved from left to right. This then gave a range of values. I subtracted the smaller value from the larger value. Then I needed to find the offset – the starting value. I then used a scale value to make my servos now respond to a range of 0 to 100. A bit difficult to describe, but a quick visit from the formula for a straight line: y = mx+c

Overall, the grid is fairly simple but it’s ideal for demonstrating control over movements, the resolution of the servos and the pen and just showing what can be done with some Lego and some servos.

Next up… hopefully bitmap conversion!

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