Starting Programming With a Flow Chart

Introduction: Starting Programming With a Flow Chart

About: Retired technology teacher - 2 kids, I have an Hons deg in Design and Technology - 28 years as Computer systems engineer Trained as Electronics engineer in the Royal Air Force

Starting to use PIC micro controllers for your projects? they are very useful but very frustrating when your programme just doesn't work.

This is one way to sort out your ideas by drawing a flow chart. This is the way professional programmers often create their masterpieces.

Starting with a simple pencil and paper to get their ideas into some form of order.

This is particularly valuable when the system you are defining is a process that moves step by step.

A good example of the would be programming an automatic washing machine or a robot. Of course for very simple programme you wouldn't need to do this.

Step 1: The Symbols

For simple flow charting you only need to use 2 symbols.

A rectangle shows an ACTION example - turn say motor on or off, turn an LED on or off.

A diamond shows a DECISION - example - is the switch on, is the lid closed, has the robot touched anything.

Step 2: Using the Symbols

Your process should fit into a step by step series of actions, Do this, Then do that, Has this happened?


Is the washing machine lid closed?

Start filling the machine

Is the machine full
Stop filling the machine

This can be represented by using the symbol boxes and writing in them what the action or decision is.

You may need to swap things around or re order them until you can see that everything is in the right order and right place so it happens at the right time.

Step 3: More Complicated Things

A more complicated programme controlling say a robot or a washing machine will have many more steps.

Step 4: Turning the Flowchart Into a Programme

This is where the flow chart scores.

It is now possible to write the necessary programming commands next to each flowchart box.

First you need to sort out what input and output is connected to what real life item.

ALL systems can be described as the following 3 sections


The input section deals with the sensors e.g. switches, ultrasonic sensors, microphones etc.

The process section is the part that makes the decisions depending on what the input sensors say.

The output section translated the small electronic signals into larger voltages and currents to drive output devices e.g. Motors, LEDs, Lamps, Speakers, etc.

This Input output table (I/O table) has 4 outputs and 1 input and would be used to control a small robot. So turning output 0 on will make the right motor go forward, turning output 0 off will stop the right motor.

Step 5: Adding to the Flow Chart

This table is easily applied to the flow chart.

Where there is an action this will normally be turn something on or off or wait for a while to allow the action to complete.

Where there is a decision normally you will be checking the inputs for any activity.

In most forms of PIC programming this will be by asking "If input x is on then do this.."

These command can be applied to the flow chart using the I/O table as below

Step 6: Turning It Into the Programme

Now we are in a good position to get a programme that will work mostly as we intend it to.

The commands can now be written into a suitable form for the programming language you are using.

I generally us the PICAXE microprocessor system this is programmed in a form of BASIC which I find easier to use for most applications.

The programme would now be written like this - I have commented this so you can see what each line does.and how it related to the flow chart.:

Start: ' this is a label so we can jump around the programme if we need to.

High 0 ' turns output 0 on
high 1 ' turns output 1 on

check: another label

If pin 3=1 then turn when input 3 is on jump to label turn

goto check ' if input 3 is not on then keep checking until it is.

low 0 ' turn output 0 off

low 1 ' turn output 1 off

high 2 turn output 2 on

high 4 ' turn output 4 on

wait 2 ' wait for 2 seconds whilst the robot backs up a bit.

low 2

low 4

goto start ' return to the start to move forward again.

Step 7: A Real PAIN

This all looks very long winded when all you want to do is get your robot/washing machine/wigit working. I agree, although this has taken me much longer to write than actually it would take to do and it is worth the effort.

1. you will find with complex programmes it is hard to get things in the right order.

2. You miss things (it's complicated)

3. Paper is cheap and your time may not be - believe me this is quicker in the long run for anything more complicated than turning an LED on and off.

4. Frustration is the killer for learning new skills, Nothing is worse than building something with electronics and it won't work, you don't know why or where to start. MUCH better to have a good chance to say well the programme should be working it must be the hardware.

Give it a try you may be surprised with the clarity of thought it give you.

Be the First to Share


    • Tinkercad to Fusion 360 Challenge

      Tinkercad to Fusion 360 Challenge
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Digital Fabrication Student Design Challenge

      Digital Fabrication Student Design Challenge



    4 years ago

    This is great a fin introduction to start with.



    11 years ago on Introduction

    I have to say, this is great. I don't think they even teach flow-charting in CS classes anymore. It's a great way to develop proper code with a logical flow.

    It's a lot better than jumping into some object oriented, nonsense that doesn't develop your thought processes. Learn logic and flow first, then screw it all up if you want later.

    Nice instructable to introduce people to a dying, but important skill.


    Reply 11 years ago on Introduction

    Thanks for you comment

    In general for anything more then trivial playing around some kind of "plan" flow chart or what ever is essential.

    No one would expect good results if you started building a house incrementally without any plan to guide you.

    What many don't realise is that transferring the flow chart to you preferred programming language is a simple matter provided you know the programming language and its syntax.

    A diamond will always be a conditional jump to another part of the programme.

    As my example is very simple and only uses 2 symbols all the rectangles are some kind of action - either inputs or outputs. Using the rest of the flow charting symbology breaks these actions down into even smaller steps that can be easily programmed.

    People are too impatient these days to take a step that in their minds lengthens the development process.

    In actual fact getting things right in the first place (on paper where it is cheap) actually shortens the overall development and ensures that everyone involved understands what is happening.