Instruction Guide: Introduction to Flow Charts

Printer-friendly version

This lesson introduces students to the concept of flow charts. Although the level of complexity in the students' programs at this point is still quite low, the introduction of flow charts at this point affords several benefits:

  • This technique appeals to visual learners as it graphically represents the programming task
  • It forces students to think logically about the entire problem, rather than just jumping in and relying on guess-and-check
  • It creates a "level of abstraction" to allow students to attack the software design problem at a higher level, without getting bogged down (or lost) in the NXT-G details
    • This will become a necessity as their program complexity grows
  • It reinforces the best-practice of "commenting" inside their NXT-G programs, by giving points of correspondence in the flow chart blocks
  • It sets students up for success with incremental/iterative software development (get one block working, then work on the next, combine those two into a working whole, then work on the next....)

This first flow chart lesson uses only the start/end, process and decision blocks.

Start by asking student if/when/where they have seen or used flow charts before:

  • Probe their responses to find preconceptions and commonality with programming flow charts

Walk students through the Flow Charts PPT presentation:

Slide 1

Display this flow chart and ask students to identify it:

  • Hopefully someone will identify it as a flow chart from the preceding challenge - The Flashlight Follower
  • Step through the flow chart to show that, indeed, this program flow would work for a Flashlight Follower
  • Pay particular attention to the two decision blocks which, by their feedback arrows, create wait loops

Slide 2

Describe the four basics elements of flow charts:

  • Start/End Blocks
    • Every program has a Start Block - on the NXT-G, this corresponds to pressing the orange button on the brick to begin running the selected program
    • Some programs do not have an End Block - the Flashlight Follower is a good example, due to it's loop-forever structure, there is no End Block
    • Some programs do have one or more End Blocks - the Dragster Challenge is a good example.
  • Process Blocks
    • These blocks "do something", and once started, go from their beginning to their end without break
  • Decision Blocks
    • These blocks, as their name implies, make a decision:
      • It is always a binary decision, with a yes or no answer
  • Program Flow Arrows give a visual indication of the direction of that the program moves between the blocks

Slide 3

This slide asks students to create a flow chart for the first Engineering Challenge they completed - the Sound Activated Dragster

  • This challenge was chosen since it should be memorable for the students, it was a simple (easy to recall) program, and it contained both Decision blocks (wait for...) and Process blocks (move)
  • Ask students to recall what this program looked like with their partner and create a flow chart to describe it

The remainder of this slide walks through the 5 steps in creating a basic flow chart:

  1. Have students break their recollection of the Dragster Challenge into separate behaviors
  2. Have students identify each behavior as a process or decision block
  3. Have students assemble these blocks in order, remembering to label both the blocks and the decision branches (Y/N)
  4. Have students add the program flow arrows
  5. Remind students about the need for Start/End blocks

Have some students share their with flow charts with the class.

Slide 4

First, step through the flow chart and compare this to the student examples - hopefully you will see some similarities, but the primary goal is illustrate all the elements of a basic flow chart.

Second, the other goal of this slide is to connect the flow chart elements with the NXT-G program elements the students are familiar with:

  • The Start block in a flow chart corresponds to the start element (always present in any NXT-G program) and shows where the program will begin running when the orange start button is pressed on the NXT brick. Every flow chart has a Start block and every NXT-G program has the Start element.

    • The End block of a flow chart may or may not appear in a flow chart (e.g. and a program with an infinite loop may not have a End block). There is no explicit End element in NXT-G, but a dangling beam after the last block serves this purpose.

      • Students learned earlier in NXT Video Trainer 2 that when a program reaches this dangling beam after the last block of a program, all the motors/sensors shut down and the program stops running.

  • Process blocks consist of one or more programming blocks which execute in order until completed. A single Process block in a flow chart may be implemented by more than one NXT-G block (like the two Move blocks used for "Go Forward" in the example) or just a single NXT-G block (like the Motor block used for "Stop").

  • Decision blocks in a flow chart correspond to some kind of input to the robot (a sensor, input button, timer, etc.), and based on this input the program makes a binary yes-or-no decision. Up to this point, the students have only used sensors for this purpose, so the Decision blocks (in their experience) correspond to Wait-for-Sensor blocks in NXT-G.

Slide 5

There is a key point to be made here about Decision blocks:

  • When a Decision block in a flow chart represents a "Wait-for" loop (such as a Wait-for-Sensor function), one of the binary branches (either Y or N, depending on the design), loops back to the beginning of the decision block to create the "Wait", while the other branch connects to the rest of the program flow (when the "Wait-for" condition has been satisfied). This can be seen in the first example on this slide and in both the flow chart examples earlier in this presentation (since these were based on programs students created using Wait-for-Sensor blocks in NXT-G).

  • Decision blocks may also be used to create two separate program flows which may, or may not, eventually tie back together and also may, or may not, eventually loop back before the same Decision block.

    • The "Parallel Branches" example creates two independent branches

    • The "Merged Parallel Branches" example creates two branches which eventually merge back into one

    • The "Looped Parallel Branches" example imbeds a Merged Parallel structure inside a loop.

  • The key point here for students to realize that Decision block can create many programming possibilities, not just the "Wait-for" loops they have seen. Students have not yet been exposed to the NXT-G blocks which enable these other structures in NXT Video Trainer 2 - but they will soon.

Slide 6

This is an optional slide that shows where these flow chart elements can be found/manipulate in LucidChart.com. Any "dumb" drawing tool (which just draws shapes, but does not understand connection/construction of flow charts) could be used, but drawing can be slow and changes can be difficult to make. Other flow chart software can also be used, but be sure to try drawing a "Wait-for" in your software before committing to it:

  • Many flow chart programs will not allow a block to feedback onto itself, as you must in a the "Wait-for" structure.
LucidChart.com will give teacher a free education account which will allow you set up separate accounts for each of your teams and have them "share" their folders with you, so you can go paperless with your flowcharts.  The LucidChart basic Flowchart menu is ideal for this lesson:
  • All the elements used in the lesson are on the top line of the menu
  • The drag-and-drop feature provides easy alignment of blocks
  • After dropping a block, labeling is one click away
  • Clicking the output terminal of a block begins drawing the next arrow with a menu for what type of block to place next
  • Decision blocks automatically label the Yes/No branches

The only default setting that is non-ideal is that the arrow-shape defaults to arced, whereas programming flowcharts usually use orthogonal arrows (this change in one extra click).

If you are not using LucidChart, skip this slide and do a live demonstration with your tool-of-choice.

Gliffy is another on line drawing software which support Flow Charts well - including the self-feedback loop.

Assessment

The Introduction to Flow Charts Task Assignment Sheet let students practice these new concepts on an everyday example.

Note: there is no separate NXT-G-based Task Assignment, since students may apply these concepts to NXT-G examples on any subsequent programming lesson challenge.