element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
STEM Projects
  • Learn
  • Learning Center
  • STEM Academy
  • STEM Projects
  • More
  • Cancel
STEM Projects
Blog The Raspberry Pi "Turtle Bot" Breaths Life Into Lesson 2
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join STEM Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: kitfud
  • Date Created: 7 Jan 2015 12:25 AM Date Created
  • Views 1765 views
  • Likes 3 likes
  • Comments 17 comments
  • raspberry pi educators design challenge
  • raspberry_pi_educator
  • pi educators sub space
  • raspberrypi_education
Related
Recommended

The Raspberry Pi "Turtle Bot" Breaths Life Into Lesson 2

kitfud
kitfud
7 Jan 2015

The school year has started again after a solid two week break.

image

 

And it was a solid two weeks of me thinking about how I was going to approach my Tuesday grind because it is every Tuesday I teach a variety of classes based on the subject of programming. These days, I'm running a very special class where I have been using the Python Programming Language with the Raspberry Pi "Turtle Bot." For an explanation of how to make the Turtle Bot and the thought that went into it please refer to my last blog post.....

 

here is the video from last week....image

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

Anyway, last night I was preparing my material and was anticipating the moment when I would break out the Turtle Bot and let it roll around my classroom floor during a lesson with my one student, William. Last lesson we programmed shapes using the "turtle" library in Python but my objective during this lesson was to bring the graphics onscreen to life by using a robot as a physical manifestation on the python turtle as the one and only "Turtle Bot."


Below is the link to the lesson plan I wrote for this lesson:

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

 

This was a lesson designed for a full 40 minute class however, because today just had to be a snow day image, with school's opening being delayed for two hours and thus all class periods shorted I ended up only 30 minutes to run my lesson image. What I realized is that things moved a bit slower than expected however, this was certainly for the better and without a doubt it was a valuable learning experience both for my student and I. In the end, I was only able to get through two of my goals from the lesson plan; 1. being to revise drawing shapes using the Python turtle library and then 2. Translating this into the "Turtle Bot's" movement when a pen is taped to the back of it image. In this way, the robot could really draw some gems (but really they were only squares)!

 

The Python code I wrote below is what I based this lesson off of :

 

import turtle
t = turtle.Pen()

def square():
    for x in range (4):
        t.forward(100)
        t.left(90)
    turtle.done()

while True:
    square()

 

This produces the following image when run in the Python IDE ("IDLE"):

image

 

After reviewing the basic Python library turtle commands with t = turtle.Pen() such as t.forward, t.left, t.right in the shell I let William attempt to write a script for drawing a square. But I did not show him the script that I had wrote earlier as I wanted him to come up with a script on his own and also, he is not familiar enough with the Python syntax to declare a "range" yet. My objective during all of this was to talk about creating a function; in our case square(). This was necessary because when using the Raspberry Pi robot I built it relies on functions from the RRB2 Motor Shield library such as forward(), backward(), left() and right(). To put these types of commands in context and to better explain them I felt it was thus necessary to relate the creation of a functions to drawing a square in Python.

 

This is what we ended up with without much guidance:

image

This code produced a square according to the function: square(). Just as planned! Oh, and of note, all this experimentation was being done on the Raspberry Pi since it has Python pre-installed on it; and just as I planned, it was being mirrored to my laptop desktop using VNC viewer:

 

image

The photo above shows William putting in dat work on the Python shell!

image

 

Now the next step after creating the square was to experiment with the movement commands for the RRB2 Motor Shield; paying particular attention to the use of functions. To reinforce this and for comparison to the script we just wrote I gave out this handout taken from the RRB2 github resource page:

 

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

 

It was fun driving the robot around in the shell, and also realizing that we were working with seconds whenever we plugged a command into a RRB2 function. For example: rr.forward(5) would cause the robot to drive forward for 5 seconds. Here is a photo of the robot in action:

image

Yes, that's the mighty turtle bot driving off into the distance! Into that mess of wires next to a desk.

 

What we realized is that if we were going to create a function for the "Turtle Bot" to draw a square and it was moving by seconds we had to figure out how many seconds it would take for the robot to turn 90 degrees in one direction. This was a fun process to figure out because I would continually replace the robot on the floor according to a tile while William experimented with different variables in the Python shell in order to find the exact amount of time it would take to rotate the beast 90 degrees. Time was quickly running out by this point and it was time! But excitement and engagement with the activity was at an all time high. With very little guidance this is the script that William wrote to get the turtle bot to draw a square on paper when a pen is attached to it:

image

Impressive stuff in a very short period of time and also considering that this is only his second time working with Python programming; the first time was two weeks ago before the winter break!

 

The end result from running this script wasn't perfect as the video will show but it did generate a lot of enthusiasm in a shot amount of time. When we get the code right and it draws squares correctly on the paper we will bundle it up into a function square() which can then be elicited by a Tkinter button. In this way, we are really working towards creating a control interface using Python to create geometric shapes in real life.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

image

 

Overall, I am looking forward to how this all evolves by next week and the feedback I got from William was that the experience was very positive and productive. So much so that we almost ran into the gym period time during our attempts to get the thing to draw a proper square! What I realized from this is that robots and movement is a great way to engage one's mind in coding. Maybe next week we will use the camera on the Raspberry Pi to take pictures of all of our progress.

  • Sign in to reply

Top Comments

  • masonc
    masonc over 10 years ago +2
    I love this visual. hands on way to show programming!
  • Robert Peter Oakes
    Robert Peter Oakes over 10 years ago +2
    One of the issues you appear to have is with turning, this may be due to the use of a tracked device rather than wheels, they tend to slide differently depending on the surface where a wheel is more lightly…
  • kitfud
    kitfud over 10 years ago in reply to masonc +1
    Thanks for the encouragement! Like my reply to you in my other post; connecting programming commands to something students can touch and feel has been very effective method. Both for motivation and also…
Parents
  • masonc
    masonc over 10 years ago

    I love this visual. hands on way to show programming!

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • kitfud
    kitfud over 10 years ago in reply to masonc

    Thanks for the encouragement! image Like my reply to you in my other post; connecting programming commands to something students can touch and feel has been very effective method. Both for motivation and also feedback when experimenting with programming commands. My lesson sequence has also been effective for me because I am introducing a personal interest of mine, locomotion in robotics. That alone allows me to remain engaged and excited about the lesson which ultimately, externalizes into enthusiasm for my student as well. If I had unlimited resources and time I would certainly have all my students creating mini robots using the Raspberry Pi or some kind of interactive art using the single board computer.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • kitfud
    kitfud over 10 years ago in reply to masonc

    Thanks for the encouragement! image Like my reply to you in my other post; connecting programming commands to something students can touch and feel has been very effective method. Both for motivation and also feedback when experimenting with programming commands. My lesson sequence has also been effective for me because I am introducing a personal interest of mine, locomotion in robotics. That alone allows me to remain engaged and excited about the lesson which ultimately, externalizes into enthusiasm for my student as well. If I had unlimited resources and time I would certainly have all my students creating mini robots using the Raspberry Pi or some kind of interactive art using the single board computer.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube