Showing posts with label Scratch programming. Show all posts
Showing posts with label Scratch programming. Show all posts

Monday, December 1, 2014

Galvanotaxis


   In biology, a taxis is the response of an organism to an environmental stimulus.           
   Galvanotaxis (or electrotaxis) is the movement of an organism in response to an electric field. 
   If platinum electrodes are inserted into a chamber filled with water containing a culture of paramecium, when an electric current is introduced into the chamber, the paramecia move towards the negative electrode.

   I simulated galvanotaxis in Scratch. Click on the play button to watch a video of the Scratch project in action.

   You can view and download the project by clicking on this link.
https://scratch.mit.edu/projects/36862440/
   A description of the code and how it works is available on request by sending an email to: 
grandadscience@gmail.com

Saturday, October 12, 2013

Spirolaterals in Scratch


   Way back in the early 1980s, the first Apple II (Integer BASIC) program I ever saw programmed a pencil and graph paper exploration called Spirolaterals. I had a lot of success using Spirolaterals with middle school and secondary students. I used them to introduce the concept of mathematical conjecture.

   The simplest spirolateral is defined as follows:
   Start at some grid point on the Cartesian plane.
      move forward x steps, turn right 90,
      move forward 2x steps, turn right 90,
      move forward 3x steps, turn right 90.
      move forward 4x steps, turn right 90
      
      move forward nx steps, turn right.

   The coefficient of the last x is called the order.
   This graphic shows the path of a 4x  or order 4 spirolateral.
   The order can be repeated and the number of repetitions is called the cycle. In the following graphic the order 3 spirolateral has been repeated 4 times, starting with the red, then the green, the blue, and finishing with the black order 3. 
 As is evident in the graphic, the order 3 cycle 4 spirolateral closes. It’s the relationship between order and cycle that can be explored and, by reviewing order-cycle data, a conjecture can be formed.
   The following graphic is a screen shot of the Scratch program that just computed the path followed by an order 9 cycle 4 spirolateral.
   This project can be viewed and downloaded by clicking on the following link.
http://scratch.mit.edu/projects/11260219/
    The second Spirolateral Scratch project mixes left and right turns. This greatly increases the number of patterns an order 5 spirolateral can compute. For example, there are 32 ways to order right and left turns for Order 5. In the graphic below, the right-right-left-right-right pattern for order 5 cycle 4 has been computed.

   This project is also a simple exercise for learning about how to store and retrieve data from a list.
   If enough data is collected by experiment, patterns in behavior do emerge. In other words, there is a relationship between order and cycle in this project that also leads to a conjecture.
   This project, Spirolateral Bot 2, can be viewed and downloaded by clicking on this link.
http://scratch.mit.edu/projects/11267799/
    Patterns really begin to get complicated (and even more interesting) when other turns, like 60 degree turns, and both left
and right turns are allowed.
   The project Spirolateral Bot 3 implements 60º right turns but can easily be modified to allow turns of any degree and both left and right turns. Doing so would make a nice exercise.
   In the graphic, an order 5 cycle 3 spirolateral has been computed.

   The project can also be viewed and downloaded by clicking on the link below.
http://scratch.mit.edu/projects/11265861/
    I do have pdf files for Spirolateral Bots 1 and 2 that go into more detail about programming spirolaterals in Scratch. To request a free copy, send an email to grandadscience@gmail.com


Sunday, December 16, 2012

Algorithmic Thinking


   
   I have just finished teaching a two-unit college course in programming for middle school and secondary math teachers. Over the years I have used BASIC, Logo, Pascal, and the version of BASIC Texas Instruments uses in their programmable calculators. The last two times I have taught the course I have used Scratch. No matter what the programming language, I have found that many math teachers have a difficult time learning to program. I have pondered this phenomenon for years because in my mind, programming should be easy for math teachers.
   Over the last few years I have created a structure that I use in the course for every programming project. I insist on participants following the seven steps of algorithmic thinking. Doing this has helped participants in my course understand that programming is not a single skill, it's a set of skills.
The Stages of Algorithmic Thinking

                       Purpose: to create machine* understandable algorithms that solve a specific problem
                                               
            First, Do the Math with Paper & Pencil Part
                                    Analyze the problem

            Next, Do the Algebraic Thinking Part
                                    Identify the Variables
                                    Determine the relationships between the variables

            And Finally, Do the Algorithmic Thinking Part
                                    Create a Logic Flow diagram
                                    Translate the relationships (math syntax) ? (computer syntax)
                                    [the syntax of every computer language is fixed and can not be violated)
                                    Combine the pieces of code (into the algorithm that solves the problem)
                                    Test the algorithm (debug)

*machine = any device controlled by digital logic [computer, smart phone, etc.]

Algorithmic Thinking Takes Place within a Problem-solving Environment


   If you teach programming for nonprofessionals, what structure do you use?

Thursday, November 29, 2012

Welcome!


   The purpose of this blog is to provide detailed information about the mathematics, science, and programming techniques embedded in the Scratch programming projects I so love doing.
   I was motivated to start this blog by a comment one viewer made in regard to a project I posted on my Scratch page at http://scratch.mit.edu/users/popswilson.
   Here is a screen shot of the project. The squareflake has the unusual property of always maintaining the same area as its originating square (in yellow) even if the perimeter is increased indefinitely by repeatedly applying the Lindenmayer rule!


   The aforementioned Scratch user had viewed my Lindenmayer System Squareflake project at 
(http://scratch.mit.edu/projects/popswilson/2909658)
and posted this comment,

AWESOME! How does it work?

   How code works is always a good question. I did include numerous comments in the Scratch scripts included in the project but they would most likely be helpful only to those that already knew something about Lindenmayer systems.
   Lindenmayer systems are not difficult to understand.  In fact, I did the project because I did not understand a Lindenmayer system!
   For those with an interest in learning the mathematics behind the code, I’ve written a detailed description of what Lindenmayer systems are, how they work, the applied mathematics, and how to program such systems in Scratch.

   To obtain a free pdf file for the Lindenmayer project simply email a request to grandadscience@gmail.com and ask for Lindenmayer Systems in Scratch.

   Registered Scratch users can download the project by clicking on the above link. To download Scratch for the PC and Mac and become a registered user go to http://scratch.mit.edu/.